我有控制的风格:
<Style x:Key="base style" TargetType="{x:Type cust:SomeCustomControl}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type cust:SomeCustomControl}">
<DataGrid >
<!-- some content... -->
</DataGrid >
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>我尝试添加另一个样式,它应该与前面的样式完全相同,但在DataGrid中的第一行使用“粗体”字体:
<Style x:Key="bold row" TargetType="{x:Type cust:SomeCustomControl}" BasedOn="{StaticResource base style}">
??????????????
??????????????
</Style>但我不明白如何在不复制“基本样式”的整个代码的情况下更改first style中的一些属性。我想我应该添加一些类似的东西:
<Style TargetType="{x:Type DataGridCell}">
<Style.Triggers>
<DataTrigger Binding="{Binding RowIndex}" Value="0">
<Setter Property="FontWeight" Value="Bold"/>
</DataTrigger>
</Style.Triggers>
</Style>但是我的“加粗行”风格适用于cust:SomeCustomControl。那么,如何才能在不覆盖整个内容情况下,实现内部的“粗体行”风格呢
<Setter Property="Template">发布于 2011-12-22 23:35:24
你不能直接把你的DataGridCell风格添加到原有风格的资源中吗?
<Style x:Key="bold row" TargetType="{x:Type cust:SomeCustomControl}" BasedOn="{StaticResource base style}">
<Style.Resources>
<Style TargetType="{x:Type DataGridCell}">
<Style.Triggers>
<DataTrigger Binding="{Binding RowIndex}" Value="0">
<Setter Property="FontWeight" Value="Bold"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Style.Resources>
</Style>它应该使用相同的模板,但继承的模板会将触发器应用于所有DataGridCell对象
https://stackoverflow.com/questions/8605081
复制相似问题