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