您好需要在 Windows Phone 的 xaml 列表框中将 6 个文本块居中。我写了这段代码
<!--ContentPanel - inserire ulteriore contenuto qui-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<ListBox x:Name="CountryListBox" HorizontalAlignment="Left" Margin="6,6,0,151" Width="444">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Height="Auto" Width="500" HorizontalAlignment="Center">
<TextBlock Text="{Binding Word}" SizeChanged="TextBox_SizeChanged" TextWrapping="Wrap" Style="{StaticResource PhoneTextExtraLargeStyle}" HorizontalAlignment="Center" FontWeight="Bold" Foreground="Red" FontSize="64"/>
<TextBlock Text="{Binding Parola1}" TextWrapping="Wrap" Style="{StaticResource PhoneTextExtraLargeStyle}" Height="70" HorizontalAlignment="Center"/>
<TextBlock Text="{Binding Parola3}" TextWrapping="Wrap" Style="{StaticResource PhoneTextExtraLargeStyle}" Height="70" HorizontalAlignment="Center"/>
<TextBlock Text="{Binding Parola4}" TextWrapping="Wrap" Style="{StaticResource PhoneTextExtraLargeStyle}" Height="70" HorizontalAlignment="Center"/>
<TextBlock Text="{Binding Parola5}" TextWrapping="Wrap" Style="{StaticResource PhoneTextExtraLargeStyle}" Height="70" HorizontalAlignment="Center"/>
<TextBlock Text="{Binding Parola2}" TextWrapping="Wrap" Style="{StaticResource PhoneTextExtraLargeStyle}" Height="70" HorizontalAlignment="Center"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<Button Content="Giusto" Height="72" HorizontalAlignment="Left" Margin="47,462,0,0" Name="button1" VerticalAlignment="Top" Width="160" Click="button1_Click" />
<Button Content="Sbagliato" Height="72" HorizontalAlignment="Left" Margin="251,462,0,0" Name="button2" VerticalAlignment="Top" Width="160" />
</Grid>
但我想用自动宽度和高度来做到这一点。有什么建议么?我还有一个小问题..如何在不使用其他对象的情况下自动调整文本块的字体大小?谢谢