删除 StackPanel / Grid 不需要的默认边框?

发布于 2024-09-24 22:18:54 字数 589 浏览 0 评论 0原文

我正在 Visual Studio 2010 中设计 UI,遇到了一个小问题。我对 XAML 和这种设计方法相当陌生,因此这可能是一个菜鸟错误。我环顾四周,但似乎找不到类似问题的参考。

基本上,我有一个包含 2 行的网格,其中一行包含一个堆栈面板和 5 列。堆栈面板位于列后面,用于绘制整行的背景。当我向另一行添加背景颜色时,我在堆栈面板的顶部看到一条恼人的线,它看起来不合适。我已经尝试了几件事(showGridLines = false,透明边框等),但似乎无法摆脱它。显示它的最佳方式是通过图像:

请参阅 http://img227.imageshack。 us/img227/2220/tempym.jpg

我注意到的一个奇怪现象是,当我调整窗口大小时,在某些点该线消失了。显然这不是一个解决方案(尤其是因为它将全屏运行),而是增加了该行的神秘感...

这是一个微不足道的问题,但它让我很烦人,并且将继续这样做,直到我可以摆脱它,所以任何帮助将不胜感激。为了简单起见,我省略了 xaml,但如果需要,我会发布。

I'm designing a UI in Visual Studio 2010, and I've come across a slight problem. I'm fairly new to XAML and this method of design, so this might be a rookie mistake. I've looked around but can't seem to find reference to a similar problem.

Basically, I have a grid with 2 rows, one of which contains a stackpanel and 5 columns. The stackpanel sits behind the columns and is used to paint the background of the entire row. When I add a background colour to the other row, I get an annoying line at the top of the stackpanel which just looks out of place. I've tried several things (showGridLines = false, transparent borders etc) but cannot seem to get rid of it. The best way to show it is through an image:

See http://img227.imageshack.us/img227/2220/tempym.jpg

One oddity I've noticed is that when I resize the window, at certain points the line disappears. Obviously this is not a solution (not least because it's going to be run full screen), but adds to the mystery of the line...

This is a trivial problem, but it is annoying me and will continue to do so until I can get rid of it, so any help would be appreciated. I've omitted the xaml for simplicity, but will post if required.

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

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

发布评论

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

评论(1

平安喜乐 2024-10-01 22:18:54

根据您注意到的奇怪现象,尝试设置 SnapsToDevicePixels 在网格或窗口上设置为 true。听起来边界落在像素边界之间并且正在消除锯齿。

或者更确切地说,如果您使用的是 .NET 4.0,请使用 UseLayoutRounding 代替。

Based on the oddity you noticed, try setting SnapsToDevicePixels to true on the grid or window. Sounds like the borders are falling in between pixel boundaries and is being anti-aliased.

Or rather, if you're using .NET 4.0, use UseLayoutRounding instead.

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