填充其父项的 ListBoxItem [英] A ListBoxItem that fills its parent

查看:36
本文介绍了填充其父项的 ListBoxItem的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发 Windows Phone 应用.

I'm developing a Windows Phone app.

我有以下 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" 我想知道还有另一种方法可以设置它来填充其父项.

Instead of setting ListBoxItem Width="444" I'm wondering it there is another way to set it that fills its parent.

有什么建议吗?

推荐答案

你能试试这个吗?

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

这篇关于填充其父项的 ListBoxItem的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆