【问题标题】:Silverlight 4.0: DataTemplate ErrorSilverlight 4.0:数据模板错误
【发布时间】:2010-04-30 00:39:11
【问题描述】:

我正在尝试在我的资源字典中获取特定模板。这是我的资源字典

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

【问题讨论】:

  • 我也有同样的问题。你找到解决这个问题的方法了吗?

标签: xaml silverlight-4.0 datatemplate resourcedictionary xamlreader


【解决方案1】:

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

【讨论】:

    【解决方案2】:

    您应该将程序集限定符添加到您的命名空间。例如,如果您的程序集名称是 SilverlightApplication1,您应该添加

    ;assembly=SilverlightApplication1

    到命名空间的末尾,如下所示:

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

    【讨论】:

      猜你喜欢
      • 2011-03-11
      • 1970-01-01
      • 1970-01-01
      • 2011-09-13
      • 2010-12-30
      • 2011-01-27
      • 2011-10-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多