【问题标题】:ResourceDictionary in WPF class libraryWPF 类库中的 ResourceDictionary
【发布时间】:2014-07-31 13:52:46
【问题描述】:

我有一个Class Library,其中包含以下代码。

下面是我的UserControlResource

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

然后我得到错误

异常:查找资源字典“pack://application:,,,/Mine.Controls;component/Templates.xaml”时出错。

我做错了什么?

【问题讨论】:

  • 你用过 Visual 2012

标签: c# wpf xaml resourcedictionary class-library


【解决方案1】:

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

【讨论】:

  • Tnx,完成了这项工作 :)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-01-19
  • 1970-01-01
  • 2011-10-26
  • 2011-12-31
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多