xaml – Windows8 ListView和项目之间的空格

我想改变listView中的项目之间的间距(也许我应该使用另一个View-element?)代码如下所示:
<ListView SelectionMode="None" HorizontalContentAlignment="Left" >
        <ListView.Items>
            <TextBlock Text="Item 1" />
            <TextBlock Text="Item 2" />
            <TextBlock Text="Item 3" />
            <TextBlock Text="Item 4" />
        </ListView.Items>
        <ListView.ItemsPanel>
            <ItemsPanelTemplate>
                <WrapGrid Orientation="Horizontal" HorizontalChildrenAlignment="left"/>
            </ItemsPanelTemplate>
        </ListView.ItemsPanel>
    </ListView>

我想尽可能模仿正常的stackpanel(wchich可以包装元素).目前空间(水平空间)之间的物品太大了.我以前的问题 – > Windows 8 WrapPanel

提前致谢

您将需要更改认模板.如果您只想简单地更改填充和边距,那么可以执行以下操作(测试代码并应该工作)
<ListView>
        <ListView.ItemsPanel>
                <ItemsPanelTemplate>
                    <WrapGrid Orientation="Horizontal" HorizontalChildrenAlignment="left"/>
                </ItemsPanelTemplate>
            </ListView.ItemsPanel>
        <ListView.ItemContainerStyle>
                <Style targettype="ListViewItem">
                    <Setter Property="Padding" Value="0"/>
                    <Setter Property="Margin" Value="0"/>
                </Style>
            </ListView.ItemContainerStyle>
            <ListViewItem>
                <TextBlock Foreground="Wheat">hej</TextBlock>
            </ListViewItem>
            <ListViewItem>
                <TextBlock Foreground="Wheat">hej</TextBlock>
            </ListViewItem>
        </ListView>

对于更多的控制,通过在设计器中右键选择一个listviewit,创建整个认模板的副本.选择编辑模板,编辑副本.这将生成认模板,您可以在那里进行更改.您可以为listviewcontainer做同样的操作.你也可以使用Blend来做到这一点.

I’ve added a description and images here (how you can edit a default template)

让我知道如何去,如果你有更多的问题!祝你好运!

编辑:

MemeDeveloper在下面提到他仍然有问题,并通过调整一些其他属性解决它 – 他发布了一个代码,并在这里回答,请务必看看.

相关文章

Windows注册表操作基础代码 Windows下对注册表进行操作使用的...
黑客常用WinAPI函数整理之前的博客写了很多关于Windows编程的...
一个简单的Windows Socket可复用框架说起网络编程,无非是建...
Windows文件操作基础代码 Windows下对文件进行操作使用的一段...
Winpcap基础代码 使用Winpcap进行网络数据的截获和发送都需要...
使用vbs脚本进行批量编码转换 最近需要使用SourceInsight查看...