I'm using the excellent MahApps library to style my WPF app and have integrated a DataGrid to display rows from a database. MahApps' default styling of the DataGrid displays the column headers in upper-case, but in my case I need to keep the original casing of the columns.
Now I'm not an expert in WPF and even less in WPF styling, so I was wondering whether there was an "easy" way to only reset the casing of the TextBlock used there, or if I had to re-define a complete DataGrid styling.
Thanks in advance, Thomas
You can do this by creating a style just for the DataGridColumnHeader, not the whole 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 (pre-release) version of MahApps (as of 29/10/2015)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With