I'm styling a listBox. i'm trying to clear the margins, so I realized which it, I set the padding of the style to 0 (left padding).
But I can still seeing some margin in it, and I need to have no margin in it? Does you know which would be the problem?
<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 can see an extra space around the item and I can't handle it to modify to 0.
That padding is hard-coded in the default template of the ListBox
, you either need to override it or modify 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 -->
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With