MahApps DataGrid Column Header Shell

I use the excellent MahApps library to build my WPF application and integrated the DataGrid to display rows from the database. By default, the MahApps DataGrid style displays the column headers in uppercase, but in my case I need to keep the original column body.

Now I am not an expert in WPF and even less in the WPF style, so I was wondering if there was a β€œsimple” way to only reset the shell of the TextBlock used there or if I had to re-define the full DataGrid style.

Thanks in advance Thomas

+5
source share
1 answer

You can do this by creating a style only for the DataGridColumnHeader, and not for the entire DataGrid:

<Window xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" ... > <Window.Resources> <Style x:Key="MyColumnHeader" BasedOn="{StaticResource MetroDataGridColumnHeader}" TargetType="{x:Type DataGridColumnHeader}"> <Setter Property="controls:ControlsHelper.ContentCharacterCasing" Value="Normal"/> </Style> </Window.Resources> ... <DataGrid ColumnHeaderStyle="{StaticResource MyColumnHeader}" ... /> ... </Window> 

Make sure you have the latest (preview) version of MahApps (as of 10/29/2015)

+12
source

Source: https://habr.com/ru/post/1234757/


All Articles