我有一个resourcedictionary里面的按钮样式,现在我想在另一个资源中多次使用这个样式(对于几个按钮),但它只是影响最后一个按钮。 这里有什么问题?如何在外部资源词典的resourcedictionary中多次使用样式?
编辑: 这是我的风格:(CommonControlStyles.xaml)
<ResourceDictionary .....>
.
.
.
<Style TargetType="{x:Type Button}" x:Key="ListButtonsStyle">
<Setter Property="MaxHeight" Value="35"/>
<Setter Property="Width" Value="20"/>
<Setter Property="Content">
<Setter.Value>
<Image Source="Images\up.png"/>
</Setter.Value>
</Setter>
</Style>
.
.
.
</ResourceDictionary>
,现在我想在另一个资源字典使用这种风格(myResourcedictionary.Xaml)
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/...StyleResource;component/CommonControlStyles.xaml" />
</ResourceDictionary.MergedDictionaries>
<Button x:Name="btn1" Grid.Column="0" Style="{DynamicResource ListButtonsStyle}"/>
<Button x:Name="btn2" Grid.Column="0" Style="{DynamicResource ListButtonsStyle}"/>
<Button x:Name="btn3" Grid.Column="0" Style="{DynamicResource ListButtonsStyle}"/>
但只是影响btn3!
请显示您的Xaml。 – Phil 2012-04-21 10:57:14
@菲尔:完成!我把xaml。 – 2012-04-23 12:08:18