Silverlight 4.0:DataTemplate错误

xsc*_*ape 5 xaml datatemplate resourcedictionary xamlreader silverlight-4.0

我试图在我的资源字典中获取特定模板.这是我的资源字典

<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>
Run Code Online (Sandbox Code Playgroud)

但是当它到达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;
    }
Run Code Online (Sandbox Code Playgroud)

找不到"SharedContainerView"类型,因为"clr-namespace:Test.Layout.View"是一个未知的命名空间.[线:4位置:56]

Joh*_*wen 3

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