WPF 用户控件作为项目模板

发布于 2024-10-05 20:18:51 字数 170 浏览 0 评论 0原文

你好 我正在尝试将按钮呈现为列表的项目模板,以水平显示。问题是他们不会互相“顶撞”。它们之间留有一个小间隙。我尝试过各种方法来治愈它,但没有成功。 有什么想法吗?

Hi
I am trying to render buttons as the item template of a list, to be displayed horizontally. The problem is that they don't 'butt up' to each other. They leave a small gap betwen each one. I have tried allsorts of things to cure it, but have'nt succeeded.
Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

风透绣罗衣 2024-10-12 20:18:51

尝试使用 WPF 工具 Snoop 找出边距的来源,然后修复它。

(负边距 = 代码异味,一般来说,IMO。)

Try using the WPF tool Snoop to work out where the margin is coming from, and then fix it.

(Negative margins = code smell, in general, IMO.)

℉絮湮 2024-10-12 20:18:51

尝试使用负边距,将 Cliptobounds 设置为 false,也许这会有所帮助

Try a negative margin, setting cliptobounds to false, maybe that can help

凶凌 2024-10-12 20:18:51

它很可能是项目容器(即 ListBoxItem,如果您使用 ListBox)上的边框、边距或填充,可以使用 ItemContainerStyle 进行更正,或者您的按钮的边框使用 BorderThickness=1、BorderBrush=Transparent 或 null。

按照丹的建议使用 Snoop 来找出答案。

It's most likely either a Border, Margin, or Padding on your item container (i.e. ListBoxItem if you're using ListBox) which can be corrected with the ItemContainerStyle or your Button's Border is using BorderThickness=1, BorderBrush=Transparent or null.

Use Snoop as Dan suggested to find out.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文