填充其父级的ListBoxItem

时间:2011-04-12 17:47:46

标签: layout windows-phone-7

我正在开发一个Windows Phone应用程序。

我有以下XAML:

<!--ContentPanel -->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
    <ListBox x:Name="SinglesGameList" Margin="0">
        <ListBoxItem Margin="10,10,10,5" Height="67" HorizontalAlignment="Center" VerticalAlignment="Center" Width="444">
            <TextBlock Text="XXX"/>
        </ListBoxItem>
    </ListBox>
</Grid>

我没有设置ListBoxItem Width =“444”,而是想知道还有另一种方法来设置它填充其父级。

有什么建议吗?

1 个答案:

答案 0 :(得分:4)

你能试试吗?

<ListBox x:Name="yourListBox">
    <ListBox.ItemContainerStyle>                    
        <Style TargetType="ListBoxItem">                       
            <Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter>                    
        </Style>
    </ListBox.ItemContainerStyle>
</ListBox>
相关问题