How to remove a small registration around ListBoxItem?

I am creating a listBox. I am trying to clear the fields, so I realized that it is, I set the style padding to 0 (left padding).

But can I still see some reserve in it, and I need not have any advantage in this? Do you know what will be the problem?

enter image description here

<ListBox ItemsSource="{Binding Partitions}"> <ListBox.ItemsPanel> <ItemsPanelTemplate> <Canvas /> </ItemsPanelTemplate> </ListBox.ItemsPanel> <ListBox.ItemContainerStyle> <Style TargetType="ListBoxItem"> <Setter Property="Padding" Value="0"/> <Setter Property="Canvas.Top"> ... </Setter> </Style> </ListBox.ItemContainerStyle> 

I mean, I see extra space around the element, and I cannot process it to change to 0.

+6
source share
1 answer

This add-on is hard-coded in the default ListBox template , you either need to override it or change it at runtime (which I would not recommend).

 <ControlTemplate TargetType="{x:Type ListBox}"> <Border Name="Bd" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" SnapsToDevicePixels="true" Padding="1"> <!-- Here --> 
+3
source

Source: https://habr.com/ru/post/911589/


All Articles