2
我有风情控制:如何应用一种风格来控制另一种风格的内部模板?
<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>
但我不明白如何在不复制“基础样式”的整个代码的情况下如何更改第一种样式的某些属性。 我想我应该添加类似:
<Style TargetType="{x:Type DataGridCell}">
<Style.Triggers>
<DataTrigger Binding="{Binding RowIndex}" Value="0">
<Setter Property="FontWeight" Value="Bold"/>
</DataTrigger>
</Style.Triggers>
</Style>
但我的“大胆行”的风格是appliable为卡斯特:SomeCustomControl。那么我怎样才能做到“大胆排列”风格,而不会覆盖整个
<Setter Property="Template">
?
这是我试过的第一件事,但它不工作,很遗憾。我没有经验的WPF程序员,所以我认为风格继承以其他方式工作。这个触发器完全被忽略。 – 2011-12-23 07:36:28