DataTemplated ListBoxItems 中的绑定错误
目前我有一个用户控件,其中包含其他视觉元素用户控件的列表框; (对于这种特殊情况)已进行数据模板化。
<Grid>
<ListBox ItemSource="{Binding Path=UserControlCollection}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<ContentPresenter Content="{Binding}"/>
<Button/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
问题是我有此问题。并且由于数据模板的原因,我似乎找不到纠正样式问题的方法。
任何帮助将不胜感激。
Currently i have a user control which contains a listbox of other visual element user controls; which (for this special case) have been data templated.
<Grid>
<ListBox ItemSource="{Binding Path=UserControlCollection}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<ContentPresenter Content="{Binding}"/>
<Button/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
The issue is that i have This Issue. And because of the data template, i can't seem to find a way to correct the styling issue.
Any help would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现通过覆盖
ListBoxItem
的水平内容对齐和垂直内容对齐我能够纠正该问题。我还发现更改为列表视图很有帮助,但确实有其自身的问题。
I found by overriding the
ListBoxItem
's horizontalcontentalignment and verticalcontentalignment i was able to correct the issue.I also found changing to a listview helpful but did have issues of its own.