从WPF ListBox中删除所有左边距,可以通过以下几种方法实现:
<ListBox.ItemContainerStyle>
<Style TargetType="{x:Type ListBoxItem}">
<Setter Property="Margin" Value="0"/>
</Style>
</ListBox.ItemContainerStyle>
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding}" Margin="0"/>
</DataTemplate>
</ListBox.ItemTemplate>
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding}" Padding="0"/>
</DataTemplate>
</ListBox.ItemTemplate>
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding}" HorizontalContentAlignment="Stretch"/>
</DataTemplate>
</ListBox.ItemTemplate>
以上方法都可以实现从WPF ListBox中删除所有左边距的效果,具体使用哪种方法需要根据具体情况进行选择。
领取专属 10元无门槛券
手把手带您无忧上云