简体   繁体   English

WPF类库中的ResourceDictionary

[英]ResourceDictionary in WPF class library

I have a Class Library with the following bits of code. 我有一个包含以下代码的Class Library

Below is my UserControl 's Resource : 下面是我的UserControlResource

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

And below here is my ResourceDictionary file named Templates.xaml : 下面是我的名为Templates.xaml的 ResourceDictionary文件:

Build action: Resource 构建行动:资源

Copy to ...: Do not copy 复制到...:不要复制

Custom tool: 自定义工具:

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

I then get the error 然后我得到了错误

Exception: An error occurred while finding the resource dictionary "pack://application:,,,/Mine.Controls;component/Templates.xaml". 例外:找到资源字典“pack:// application:,,, / Mine.Controls; component / Templates.xaml”时发生错误。

What am I doing wrong? 我究竟做错了什么?

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM