I have datagrid with the hierarchy like this..
I want to style textblock in datagrid to have horizontal alignment to Center like picture above.
Can you help me How I can achieve this? With WPF Styling?
You could use a DataGridTemplateColumn.
<DataGrid>
<DataGrid.Columns>
<DataGridTemplateColumn Header="Key">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock HorizontalAlignment="Center" Text="{Binding Key}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.