5

我试图让我的资源字典中的特定模板。这是我的资源字典Silverlight 4.0:DataTemplate错误

<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> 

但是当它到达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; 
    } 

类型 'SharedContainerView' 没有被发现,因为“CLR的命名空间:Test.Layout.View'是一个未知的命名空间。 [Line:4 Position:56]

+0

我有同样的问题。你找到了解决这个问题的方法吗? – Gaby 2011-07-25 12:42:54

+0

@Gaby还没有.. – xscape 2011-07-25 13:17:27

回答

3

您是否试过将程序集限定符添加到xmlns:view?

3

您应该为您的名称空间添加程序集限定符。例如,如果你的程序集的名字是SilverlightApplication1你应该添加

;装配= SilverlightApplication1

到您的命名空间的结尾如下:

的xmlns:鉴于=“CLR的命名空间:Test.Layout.View ;程序集= SilverlightApplication1“