Axa*_*dax 5 c# listview windows-runtime winrt-xaml windows-store-apps
我想水平排列一些TextBlocks,没有任何边距.我可以看到我的TextBlock尽可能小,但由于某些原因,它周围增加了很多空间.我认为它与ListView或其样式有关,但我不知道是什么.

我有以下布局:
<ListView Width="Auto" SelectionMode="None" Background="#654321" ItemsSource="{Binding}">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListView.ItemTemplate>
<DataTemplate>
<Border Background="Black">
<TextBlock Text="{Binding}" Margin="0,0,0,0"/>
</Border>
</DataTemplate>
</ListView.ItemTemplate>
<x:String>A</x:String>
<x:String>B</x:String>
<x:String>C</x:String>
<x:String>D</x:String>
<x:String>E</x:String>
</ListView>
Run Code Online (Sandbox Code Playgroud)
从另一种角度来看,它ListView实际上被设计为一个控件,您可以在其中点击、选择、拖动以及以其他方式与项目进行交互。我认为如果你想删除所有确保尺寸可以用胖手指触摸的功能 - 你可能最好使用像底座这样的东西ItemsControl或者ListBox可能没有这些限制的东西。如果你去掉所有的边距并让你的项目如此之小 - 使用它是没有意义的ListView,它只会使事情变得复杂并使性能变差。