【发布时间】:2016-04-06 09:31:50
【问题描述】:
如何在用户控件库中定义 ResourceDictionary 并通过 Xaml-Code 访问它们。
我创造了这样的东西:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
xmlns:Dialog="clr-namespace:MahApps.Metro.Controls.Dialogs;assembly=MahApps.Metro"
>
<Style x:Key="NormalStyle" TargetType="{x:Type Control}">
<Setter Property="Foreground" Value="Black" />
<Setter Property="FontSize" Value="12" />
<Setter Property="FontFamily" Value="Arial" />
<Setter Property="FontStyle" Value="Normal" />
</Style>
.
.
.
</ResourceDictionary
现在我想将这个“NormalStyle”与控件一起使用
Style="{StaticResource NormalStyle}"
但 Visual Studio 显示“无法解析资源“NormalStyle”。” 我错过或忘记了什么吗?
谢谢你帮助我
【问题讨论】:
标签: wpf user-controls resourcedictionary