我试图在我的资源字典中获取特定模板。这是我的资源字典
<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-namespace:Test.Layout.View”是未知命名空间。[行:4 位置:56]