【问题标题】:How Can i address theme in other solution in wpf我如何在 wpf 的其他解决方案中解决主题
【发布时间】:2012-12-03 08:38:56
【问题描述】:

我有一个包含多个解决方案的项目。在我的核心解决方案中,我有一个包含我的主题的主题文件夹。在 shell 解决方案和 App.xaml 文件中,我想解决我的主题。像这样:

<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="/Hezareh.Core;component/Themes/CustomDocumentViewerTemplate.xaml" />
            <ResourceDictionary Source="/Hezareh.Core;component/Themes/Darkness.xaml" />
            <ResourceDictionary Source="/Hezareh.Core;component/Themes/Generic.xaml" />
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Application.Resources>

但我收到此错误:

设置属性“System.Windows.ResourceDictionary.Source”引发异常。

【问题讨论】:

    标签: wpf xaml exception resourcedictionary


    【解决方案1】:

    您可以像这样更改您的代码:

        <Application.Resources>
            <ResourceDictionary>
                <ResourceDictionary.MergedDictionaries>
                    <ResourceDictionary Source="pack://application:,,,/Hezareh.Core;component/Themes/CustomDocumentViewerTemplate.xaml" />
                    <ResourceDictionary Source="pack://application:,,,/Hezareh.Core;component/Themes/Darkness.xaml" />
                    <ResourceDictionary Source="pack://application:,,,/Hezareh.Core;component/Themes/Generic.xaml" />
                </ResourceDictionary.MergedDictionaries>
            </ResourceDictionary>
        </Application.Resources>
    

    【讨论】:

    • 亲爱的 Niki Nikpour。我仍然收到此错误“无法找到资源'themes/customdocumentviewertemplate.xaml'。”
    【解决方案2】:

    我自己找到了解决这个问题的方法。

    为了解决这个问题,我们应该右键单击主题文件并单击属性。

    在属性窗口中将构建操作设置为页面。

    【讨论】:

      猜你喜欢
      • 2015-10-25
      • 1970-01-01
      • 2015-09-12
      • 1970-01-01
      • 2020-07-01
      • 1970-01-01
      • 2020-02-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多