wpf - 如何将控件模板添加到资源字典?
问题描述
所以我想创建一个ComboBox的模板副本,但不是在MainWindow中定义它,而是在一个专门创建的资源目录中。
我得到了什么:
<Application x:Class="dingeTesten.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:dingeTesten"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ResourceDictionary Source="Dictionary1.xaml"/>
</Application.Resources>
现在我创建了一个名为 Dictionary1.xaml 的 RessourceDictionaray。在这个文件中,我想要我的 ComboBox 的模板副本,但是当我创建一个模板时,我无法选择这个文件:
它是德语的,但我不能选择最后一个选项 RessourceDictionary 来将此模板保存在我的 RessourceDictionary 中。
解决方案
我想您正在尝试为ComboBox
in创建一种样式Blend
。要启用选项,Resource dictionary
您必须添加ResourceDictionary
到MergedDictionaries
.App.xaml
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Dictionary1.xaml"/>
<ResourceDictionary Source="Dictionary2.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
然后Resource dictionary
选项将被启用。
推荐阅读
- java - 休眠,如果拥有的实体相同,则使用已在数据库中持久化的实体与拥有方链接,而不是创建新实体
- java - 在 docker 中运行的应用程序无法与 elasticsearch docker 连接
- html - 在网格布局中,使图像适合其包含单元格的高度
- ios - 仅将应用程序分发给我的客户并在已将我的应用程序上传到 Appstore 的情况下进行白标
- html - 如何为卡片组中的每个反应引导卡添加图像滑块
- html - 如何让 :before 标签显示在 ul 元素之上?
- ios - 如何在 Windows 10 中使用 Flutter 构建 iOS 应用程序
- javascript - 如何选择相同标签但不同类的多个元素?使用香草 JS
- javascript - 将 Code 标签内的代码复制到剪贴板 reactJS
- sas - SAS 宏:如何在一个数据集中记录 proc 表示输出?