5
我定义自定义查找资源字典Button控件:WPF - 在字典中定义与父控件定义的样式混合款式
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style TargetType="Button" x:Key="BaseButtonStyle">
<Setter Property="Background" Value="Blue"/>
</Style>
</ResourceDictionary>
然后我试图改变风格在窗口中的按钮的位置。
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Dictionary.xaml"/>
<ResourceDictionary>
<Style TargetType="Button" BasedOn="{StaticResource BaseButtonStyle}">
<Setter Property="Foreground" Value="Red"/>
</Style>
</ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
在WPF设计师我有我的预期。与红色文本的蓝色按钮。 但是在运行时,两种样式都未应用,并且按钮具有默认颜色。 我该如何解决这个问题?
你能分享xaml吗? – 2010-09-23 13:49:54