无法删除ListBoxItem填充 [英] Cannot remove ListBoxItem padding
问题描述
亲爱的,
我有一个奇怪的问题,我无法搭乘。
I have a weird issue I cannot get ride of.
我有一个显示为的图表一个ListBoxItem,如下图所示:
I have a chart which is display as a ListBoxItem as seen in picture below :
从上图中可以看出,我需要从左侧完美对齐2个图表。但正如您可以看到下面的图表,它是列表框的一部分,它在左侧有一个空格,导致该图表不与顶部图表对齐。
From the picture above it represent 2 charts that I need to be perfectly align from left. but as you can see the below chart, it is part of a listbox and it has on the left side a space which cause that chart not being align from top chart.
我试过设置我的itemsContainerStyle如下:
I have try to set my itemsContainerStyle as below :
<Style TargetType="ListBoxItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="IsSelected" Value="{Binding IsChartSelected}" />
<Setter Property="Padding" Value="0"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListBoxItem}">
<ContentPresenter/>
</ControlTemplate>
</Setter.Value>
</Setter>
正如您所见,我在ListBoxItem中填充为0,但仍然显示此间距。
As you can see I am seetin the padding fro ListBoxItem to be 0, but still I have this spacing appears.
然后我通过使用Visual Studio Live可视树功能指出它显示的对象来探索我的视觉tre。然后我注意到它属于ListBox.Scrollviewer,它在ListboxItem边缘之间保留了一些空间。
Then I explore my visual tre by using Visual Studio Live visual tree feature to point out which object it shows. Then I notice it belongs to the ListBox.Scrollviewer which reserve some space between ListboxItem edges.
我不知道如何去除这个空间。
I do not knoy what to do in order to remove this space .
知道我做错了怎么样或者做错了什么?
Any idea how or what I am doing wrong ?
如果无法删除,我怎样才能获得这个空间宽度以便将它绑定到我的第一个顶级图表边距左边的财产?
In case it cannot be remove, how can I get this space Width in order to bind it to my First top chart margin Left property ?
感谢您对此的宝贵帮助让我发疯。
Thanks for your precious help on this which drive me crazy.
问候
推荐答案
您好wakefun,
Hi wakefun,
您能否通过OneDrive分享完整的样本,可以重现问题。
Could you please share a complete sample via OneDrive, which could reproduce the issue.
祝你好运,
张龙
这篇关于无法删除ListBoxItem填充的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!