Windows phone での要素の配置に常に問題がありました。誰かが私を助けてくれることを願っています:私はリストボックスをコードビハインドから動的に入力しました:
<ListBox Name="list" Grid.Row="1" HorizontalAlignment="Center">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}" Style="{StaticResource list_service_item}"/>
</DataTemplate>
</ListBox.ItemTemplate>
スタイルは App.xaml で定義されています。
<Style x:Key="list_service_item" TargetType="TextBlock">
<Setter Property="FontSize" Value="25"/>
<Setter Property="FontWeight" Value="Bold"/>
<Setter Property="Foreground" Value="Peru" />
<Setter Property="TextWrapping" Value="Wrap"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="Margin" Value="0 0 0 5"/>
</Style>
配置プロパティを除いて、正しく機能しているように見えます。
リストボックスのアイテムが同じ長さの場合はすべてうまく機能しますが、そのうちの 1 つが長い場合、他のすべてのアイテムは中央に配置されずに、長いアイテムの先頭に揃えられます。
どうすればこれを解決できますか?