XAML ListView ItemContainer高度 [英] XAML ListView ItemContainer Height

查看:93
本文介绍了XAML ListView ItemContainer高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想更改ItemContainerHeight而不是容器本身位于ListView

I want to Change the Height of the ItemContainer and not the Heightof the Item itself the Container is in a ListView

我要更改的内容:

对于这样的事情:

代码的结构如下:

 <ListView>
                        <ListView.ItemTemplate>
                            <DataTemplate>
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition/>
                                        <ColumnDefinition/>
                                    </Grid.ColumnDefinitions>
                                    <TextBlock Text="{Binding A}" Grid.Column="0"/>
                                    <TextBlock Text="{Binding B}" Grid.Column="1"/>
                                </Grid>
                            </DataTemplate>
                        </ListView.ItemTemplate>
                    </ListView>

希望获得帮助

推荐答案

您需要更改ListView中出现的所有ListViewItem元素的MinHeight.您可以使用Style来实现.

You need to change the MinHeight of all ListViewItem elements that appear in your ListView. You can achieve this by using a Style.

<ListView>
    <ListView.ItemContainerStyle>
        <Style TargetType="ListViewItem">
            <Setter Property="MinHeight" Value="0"/>
            <Setter Property="Padding" Value="6,3"/>
        </Style>
    </ListView.ItemContainerStyle>

    <TextBlock Text="Hello"/>
    <TextBlock Text="World"/>
</ListView>

使用Padding也是一个好主意,因为您不希望每个列表视图项都太薄了.

Using Padding with this method is also a good idea as you do not want each list view item to be too thin.

这篇关于XAML ListView ItemContainer高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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