哪里有利润/填充上一个WPF的ListView GridView的设置? [英] Where are the margins/padding set on a wpf ListView GridView?

查看:202
本文介绍了哪里有利润/填充上一个WPF的ListView GridView的设置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有在XAML只具备一个WPF的ListView / GridView控件。第一列使用一个CellTemplate来指定图标和其他人使用DisplayMemberBinding填充自己。图标列是20宽,16图标,但他们要通过利润/填充/东西截断。其中,它的设置,我不能工作了。

I've got a WPF ListView/GridView spec'd in XAML. The first column uses a CellTemplate to specify icons and the others use DisplayMemberBinding to populate themselves. The icons column is 20 wide, the icons 16 but they're getting truncated by margins/padding/something. I can't work out where it's set.

下面是要领(我已经删除了一些列,因为它们是相同的):

Here's the essentials (I've removed some columns because they're the same):

<ListView.ItemContainerStyle>
    <Style TargetType="{x:Type ListViewItem}">
        <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
        <Setter Property="FontWeight" Value="Normal" />
        <Style.Triggers>
            <Trigger Property="IsSelected" Value="True">
                <Setter Property="FontWeight" Value="Bold" />
            </Trigger>
        </Style.Triggers>
    </Style>
</ListView.ItemContainerStyle>

<ListView.Resources>
    <DataTemplate x:Key="image">
        <Image Width="16" Height="16" Margin="0,0,0,0"
                          HorizontalAlignment="Center"
                          Source="{Binding Path=ObjectType, 
                                           Converter={StaticResource imageConverter} }" />
    </DataTemplate>
</ListView.Resources>

<ListView.View>
    <GridView>
        <GridViewColumn Width="20"
                        CellTemplate="{StaticResource image}"/>
        <GridViewColumn Width="120" Header="Name"
                        DisplayMemberBinding="{Binding Path=Name}"/>
    </GridView>
</ListView.View>

ImageConverter只是打开了一个对象类型为图像所以每个类型的项目都有自己的图标。

ImageConverter just turns an ObjectType into an image so each type of item gets its own icon.

推荐答案

使用史努比弄清楚该元素是负责征收额外的间距。将鼠标移到空间并按住控制和转移。该元素将随后在可视化树中突出显示。

Use Snoop to figure out which element is responsible for imposing the extra spacing. Mouse over the space and hold down control and shift. The element will then be highlighted in the visual tree.

这篇关于哪里有利润/填充上一个WPF的ListView GridView的设置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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