gpt4 book ai didi

c# - WPF 类库中的 ResourceDictionary

转载 作者:行者123 更新时间:2023-12-02 21:26:07 50 4
gpt4 key购买 nike

我有一个包含以下代码的类库

下面是我的UserControl资源:

<UserControl.Resources>
<ResourceDictionary Source="pack://application:,,,/Mine.Controls;component/Templates.xaml" />
</UserControl.Resources>

下面是我的 ResourceDictionary 文件,名为 Templates.xaml:

构建操作:资源

复制到...:不要复制

自定义工具:

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ControlTemplate x:Key="MyButton"
TargetType="Button">
<Border x:Name="buttonBorderOuter"
BorderBrush="#DBDBDB"
BorderThickness="1"
Background="#00ECECEC"
CornerRadius="5" />
</ControlTemplate>
</ResourceDictionary>

然后我收到错误

Exception: An error occurred while finding the resource dictionary "pack://application:,,,/Mine.Controls;component/Templates.xaml".

我做错了什么?

最佳答案

尝试将 Templates.xaml 的构建操作更改为 Page

关于c# - WPF 类库中的 ResourceDictionary,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24147129/

50 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com