Answer the question
In order to leave comments, you need to log in
How to create a common property for elements?
Good evening everyone. Please give an example of a common property for elements. For example, I have many elements, and they have the "Width" property, so that for each the same width number is not written, how can I make a general one? That is, so that all elements refer to one line.
Answer the question
In order to leave comments, you need to log in
You must specify the type of elements that you want to style. In a DataGrid, the cells are in the DataGridCell element and the headers are in the DataGridColumnHeader.
<DataGrid>
<DataGrid.Columns>
<DataGridTextColumn Header="Qwe"/>
<DataGridTextColumn Header="Rty"/>
<DataGridTextColumn Header="Uio"/>
</DataGrid.Columns>
<DataGrid.Resources>
<Style TargetType="DataGridColumnHeader">
<Setter Property="Width" Value="100"/>
</Style>
</DataGrid.Resources>
</DataGrid>
<DataGrid.ColumnHeaderStyle>
<Style TargetType="DataGridColumnHeader">
<Setter Property="Width" Value="100"/>
</Style>
</DataGrid.ColumnHeaderStyle>
<DataGrid.ColumnHeaderStyle>
<Style TargetType="DataGridColumnHeader" BasedOn="{StaticResource {x:Type DataGridColumnHeader}}">
<Setter Property="Width" Value="100"/>
</Style>
</DataGrid.ColumnHeaderStyle>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question