如何让这个listBox项目垂直伸展?

时间:2012-12-14 12:54:29

标签: windows-phone-7 xaml

__________________________
__________Item1____________
__________Imemnumber2_____
__________Item3____________
__________________________

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <ListBox x:Name="MainListBox" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,0,-12,0" ItemsSource="{Binding Items}" SelectionChanged="MainListBox_SelectionChanged" >
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel  Margin="10">
                            <Image Source="{Binding Image}" Stretch="None"/>
                            <TextBlock Text="{Binding Title}" TextWrapping="Wrap" Style="{StaticResource PhoneTextExtraLargeStyle}"/>
                        </StackPanel>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
        </Grid>

我该怎么做?

____________________________
___________Item1_____________
_________Imemnumber2________
___________item3_____________
____________________________

1 个答案:

答案 0 :(得分:0)

尝试设置TextBox的TextAlignment属性

<TextBlock Text="{Binding Title}" TextWrapping="Wrap" Style="{StaticResource PhoneTextExtraLargeStyle}" TextAlignment="Center"/>

更新:

尝试修复TextBlock的宽度,如下所示

<TextBlock Text="{Binding Title}" TextWrapping="Wrap" Style="{StaticResource PhoneTextExtraLargeStyle}" TextAlignment="Center" Width="400"/>