Utwórz styl dla TextBlock w DataGridTextColumn

Chcę stworzyć globalny styl, który ustawiaVerticalAlignment doCenter dla wszystkichTextBlock elementy sterujące wewnątrz aDataGrid lub w środkuDataGridTextColumn.

Nie chcę kopiować następujących na każdyDataGridTextColumn ponieważ jest to powtarzalne.

<DataGridTextColumn Header="Some Property" Binding="{Binding SomeProperty}">
    <DataGridTextColumn.ElementStyle>
        <Style TargetType="TextBlock">
            <Setter Property="VerticalAlignment" Value="Center"></Setter>
        </Style>
    </DataGridTextColumn.ElementStyle>
</DataGridTextColumn>

Próbowałem czegoś takiego jak poniżej, ale to nie działa, ponieważDataGridTextColumn nie dziedziczy poFrameworkElement lubFrameworkContentElement. DataGrid Samo to robi, ale każde kolejne opakowanie, które próbuję, prowadzi do błędów:

<Style TargetType="DataGridTextColumn">
    <Setter Property="ElementStyle">
        <Setter.Value>
            <Style TargetType="TextBlock">
                <Setter Property="VerticalAlignment" Value="Center"/>
            </Style>
        </Setter.Value>
    </Setter>
</Style>

questionAnswers(3)

yourAnswerToTheQuestion