ItemsPanelTemplate に UniformGrid を使用したリストボックスがあります。写真一覧です。写真をグリッドの各セルの中央に水平方向に配置したいのですが、何をしても画像が各セルの左側に配置されているようです。これが私の現在のXAMLです:
<Border BorderThickness="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" DockPanel.Dock="Right">
<ListBox Name="PhotosListBox" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Disabled">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid IsItemsHost="True" HorizontalAlignment="Center"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<Image Source="{Binding Path=photo}" HorizontalAlignment="Center"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Border>
ご覧のとおり、DataTemplate の Image コントロールを HorizontalAlignment="Center" に設定していますが、これでうまくいくと思っていましたが、うまくいきません。
私は何を間違っていますか?