Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Silverlight 4.0: DataTemplate Error

Im trying to get the specific template in my resource dictionary. This is my resource dictionary

<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
xmlns:view="clr-namespace:Test.Layout.View"
xmlns:toolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"  
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"><DataTemplate x:Key="LeftRightLayout">
    <toolkit:DockPanel>
        <view:SharedContainerView toolkit:DockPanel.Dock="Left"/>
        <view:SingleContainerView toolkit:DockPanel.Dock="Right"/>
    </toolkit:DockPanel>
</DataTemplate>

However when it gets to XamlReader.Load

private static ResourceDictionary GetResource(string resourceName)
    {
        ResourceDictionary resource = null;

        XDocument xDoc = XDocument.Load(resourceName);
        resource = (ResourceDictionary)XamlReader.Load(xDoc.ToString(SaveOptions.None));

        return resource;
    }

The type 'SharedContainerView' was not found because 'clr-namespace:Test.Layout.View' is an unknown namespace. [Line: 4 Position: 56]

like image 999
xscape Avatar asked Apr 30 '10 00:04

xscape


2 Answers

Have you tried adding an assembly qualifier to the xmlns:view?

like image 152
John Bowen Avatar answered Oct 18 '22 06:10

John Bowen


You should add an assembly qualifier to your namespace. For example if your assembly name is SilverlightApplication1 you should add

;assembly=SilverlightApplication1

to the end of your namespace as following:

xmlns:view="clr-namespace:Test.Layout.View;assembly=SilverlightApplication1"

like image 32
Ebrahim Asadi Avatar answered Oct 18 '22 04:10

Ebrahim Asadi