在app.xaml wpf中导入多个资源文件

传说

[在Windows 8上运行]我知道如何导入一个,例如:

<Application.Resources>
        <ResourceDictionary Source="Styles\MyCombobox.xaml"/>       
 </Application.Resources> 

但我想要这样的东西:

<Application.Resources>
        <ResourceDictionary Source="Styles\X.xaml"/>       
        <ResourceDictionary Source="Styles\Y.xaml"/>       
        <ResourceDictionary Source="Styles\Z.xaml"/>       
 </Application.Resources> 

我得到:

属性资源只能设置一次!

在此处输入图片说明

哈姆雷特·哈科比

您应该合并这些字典。

<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="Styles\X.xaml"/>       
            <ResourceDictionary Source="Styles\Y.xaml"/>       
            <ResourceDictionary Source="Styles\Z.xaml"/>       
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Application.Resources>

更多文档

更新

当然,您应该将属性用法包装在ResourceDictionary标记中。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

更新通用Windows App XAML中的资源

WPF c#app.xaml意外删除

从 app.xaml /wpf 设置图像源

WinRT在Universal App中使用共享资源xaml文件

如何从 Xamarin Forms 的 ContentPage 保存 App.xaml 中的资源?

App.xaml中基于ResourceDictionary的WPF样式

在 App.xaml 样式 WPF 中访问用户控件属性

无法从WPF中的app.xaml覆盖按钮样式

WPF重用XAML资源

使用XAML文件(Xamarin)中的资源文件

将app.xaml样式拆分为文件

App.xaml指向子文件夹中的库

读取XAML外部库中的资源文件

在Xamarin.Forms中的XAML中使用资源文件

XAML文件(WPF)的编译

有没有一种方法可以消除对App.Xaml的需要并将资源添加到App.Xaml.cs的方法?

在 App.xaml.cs 或应用程序启动时在 ContentRegion(Prism) 中导航视图(登录)

如何以编程方式从App.xaml访问资源字符串?

如何在单个App.xaml中合并不同的资源?

如何在 App.xaml 静态资源中使用嵌套字符串...?

如何在 C# ContentPage 中访问 App.xaml 上的静态资源模板?

从控制台应用程序运行WPF应用程序时,App.xaml被忽略

将 App.xaml 设置为 UserControl WPF(连接定位器)

在WPF中,如何从合并的字典中引用App.xaml中的StaticResource

WPF将第三方ResourceDictionary添加到App.xaml?

从App.xaml.cs WPF按顺序启动两个窗口

如何通过 WPF 中的 App.Current 从主 App.xaml.cs 类中获取非静态字段?

XAML在未处理的异常和app.gics文件上生成的中断是什么

如何在app.xaml.cs文件中动态更改应用程序的主题