一定の幅のリストボックスがあります。リストボックス内のアイテムの数は異なります。リストボックスの内容を中央に配置する方法はありますか?ListBoxItemの「コンテンツプレゼンター」は、リストボックスの幅全体に対して中央に配置するのではなく、テンプレート内の各アイテムを中央に配置します。
先に返信しなくてすみません。問題は、リストボックスで使用していたItemsPanelTemplateの幅にありました。以前の幅は925に設定されていました。この幅をMaxWidthに変更すると機能しました。コード:
<ItemsPanelTemplate x:Key="ItemsPanelKey">
<Contact:AnimatedWrapPanel HorizontalAlignment="Center" MaxWidth="925">
<Contact:AnimatedWrapPanel.Interpolation>
<interpolate:BackInterpolation Amplitude=".5" Suppression=".2" EdgeBehavior="5"/>
</Contact:AnimatedWrapPanel.Interpolation>
</Contact:AnimatedWrapPanel>
</ItemsPanelTemplate>