我有一个ListView即是这样的:WPF ListView在内部布局面板周围有一个像素边框。我如何摆脱它?
<ListView
x:Name="SeriesListView"
SnapsToDevicePixels="True"
ItemsSource="{Binding Items}"
BorderBrush="Transparent" BorderThickness="0"
Padding="0" Margin="0"
VerticalContentAlignment="Top"
Background="Purple"
LostFocus="ListView_LostFocus"
>
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<local:LDSeriesPanel
SnapsToDevicePixels="True"
MaxWidth="{Binding ElementName=itControl,Path=ActualWidth}"
VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
MinHeight="{x:Static local:LDSeriesPanel.MIN_HEIGHT}"
MinWidth="{x:Static local:LDSeriesPanel.MIN_WIDTH}"
Margin="0"
Background="Aquamarine"/>
</ItemsPanelTemplate>
</ListView.ItemsPanel>
</ListView>
当它是空的,宽度和我定义的自定义面板的高度是15×15,我可以证实,这些都是在运行时的实际尺寸。但是,ListView本身的尺寸为17 x 17(即面板和ListView之间的一个像素边框)。
从自定义面板启动和走了树,我碰到下面的祖先:
- ItemsPresenter:15×15
- 的ScrollViewer:15×15
- 格:15×15
- 的ScrollViewer:15×15
- 边框:17x17
- 列表视图:17x17
如果我将ListView上的填充更改为-1,它将删除边框但会导致其他几个问题。
我希望避免retemplating整个ListView。其他一切工作正常。有什么方法可以删除这一个像素边框,也许是通过一种风格?
哎呀....确定。 :( – 2010-06-21 02:10:24
我最终使用了一个ListBox来代替,但我会给你勾号的。这个问题的竞争很激烈......) – 2010-06-23 16:18:48