开发者

Changing one property of template in control

开发者 https://www.devze.com 2023-04-06 06:49 出处:网络
I have got a datagri开发者_StackOverflowd and it has declared ColumnHeaderStyle=\"{StaticResource DataGridColumnHeaderStyle}\"

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

精彩评论

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