MahApps customization style based on existing style has strange result

I copied the MahApps source code DataGrid

and it works fine if I change the styling directly, such as HorizontalAlignment

left to right setting . But if I did

 <Style BasedOn="{StaticResource MetroDataGridColumnHeader}" TargetType="{x:Type DataGridColumnHeader}"
     x:Key="MetroDataGridColumnHeader1">
     <Setter Property="HorizontalAlignment" Value="Right"></Setter>
 </Style> 

      

and replace MetroDataGridColumnHeader

with a new one MetroDataGridColumnHeader1

inside the DataGrid style, it gives weird output. Meter effects disappear. Any ideas?

enter image description here

+3


source to share


1 answer


You must install HorizontalContentAlignment

not HorizontalAlignment

.

<Style BasedOn="{StaticResource MetroDataGridColumnHeader}"
        TargetType="{x:Type DataGridColumnHeader}"
        x:Key="RightAlignmentMetroDataGridColumnHeader">
    <Setter Property="HorizontalContentAlignment"
            Value="Right" />
</Style>

      



enter image description here

Hope it helps.

+4


source







All Articles