我有一個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