开发者

Changing one property of template in control

I have got a datagri开发者_StackOverflowd and it has declared

ColumnHeaderStyle="{StaticResource DataGridColumnHeaderStyle}"

and in this style I have

    <Setter Property="Padding" Value="4" />

How can I change padding of header at particular column without changing style?

I need to do it, because at start I have cut headertext, and I need decrease padding to 2 at this column to display full text.


Create another Style using BasedOn property to re-use the exisitng style:-

 <Style x:Key="SpecialDataGridColumnHeaderStyle" BasedOn="{StaticResource DataGridColumnHeaderStyle}" TargetType="DataGridColumnHeader">
     <Setter Property="Padding" Value="4" />
 </Style>

Now on the specific DataGridColumn you can assign this special style to the HeaderStyle

<DataGridTextColumn ... HeaderStyle="{StaticResource SpecialDataGridColumnHeaderStyle}" /> 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜