Я пытаюсь центрировать изображение внутри ячейки DataGrid.Я пробовал весь текущий код одновременно и каждое «центрирующее» решение по одному и все еще центрировал изображение слева.
<DataGrid ItemsSource="{Binding PhotoList, Mode=TwoWay, NotifyOnSourceUpdated=True, UpdateSourceTrigger=PropertyChanged}"
Grid.Row="1"
x:Name="dataGridPhotos"
Margin="5 5 5 5"
CanUserAddRows="False"
CanUserDeleteRows="True"
AutoGenerateColumns="False"
HorizontalContentAlignment="Center">
<DataGrid.Columns>
<DataGridTemplateColumn>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Image Source="{Binding PhotoSource}"
Width="320px"
Height="240px"
Stretch="Uniform"
Margin="0"
HorizontalAlignment="Center"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
<DataGrid.CellStyle>
<Style TargetType="DataGridCell">
<Setter Property="HorizontalAlignment" Value="Center"/>
</Style>
</DataGrid.CellStyle>
</DataGrid>