高缩放级别圆形边框周围的白线

发布于 2024-08-09 20:13:50 字数 504 浏览 2 评论 0原文

如果我在 xamlpadx 中放大到足够大(500%),我会看到边框内部周围的线条。在我的应用程序中,这种情况甚至会在某些控件的正常缩放级别发生。

为什么会这样,更重要的是,我能做些什么呢?

这是我的 XAML 代码:

<Border Background="#000000" BorderBrush="#000000" BorderThickness="4" CornerRadius="4">    
   <StackPanel>               
   </StackPanel>
</Border>

我删除了所有内容,直到我确定有缺陷的显示中不涉及任何填充/边距/边框。

编辑2: 我不应该这么快就接受答案。我注意到,在相同的情况下,错误与以前一样,尽管我使用了 SnapsToDevicePixels 并将控件的内部颜色设置为与边框相同的颜色。希望微软尽快解决这个问题!

If I zoom large enough in xamlpadx (500%) I see while lines around the inside of the border. In my app this even happens at normal zoom level in some controls.

Why is that and more important, what can I do about it?

This is my XAML code:

<Border Background="#000000" BorderBrush="#000000" BorderThickness="4" CornerRadius="4">    
   <StackPanel>               
   </StackPanel>
</Border>

I removed everything until I was sure that no padding/margin/border is involved in the flawed display.

EDIT 2:
I shouldn't have accepted the answer so soon. I noticed that in same cases the error is as before, although I used SnapsToDevicePixels and set the interior color of the control to the same color as the border. I hope microsoft will fix this soon!

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

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

发布评论

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

评论(3

忘年祭陌 2024-08-16 20:13:50

我有同样的行为,我认为这是 WPF 渲染引擎的错误。
通过将 SnapsToDevicePixels="True" 添加到边框,您可以获得稍微更好的结果:白线仅保留在圆角中。

I have the same behavior and I think that it is an error of the WPF rendering engine.
You get slightly better results by adding SnapsToDevicePixels="True" to the Border: the white lines remain only in the rounded corners.

往日 2024-08-16 20:13:50

这确实是 WPF 中的一个错误。但是,对于您的具体情况,您可以使用两种解决方法:

<Border Background="#000000" BorderThickness="0" CornerRadius="4">
   <StackPanel Margin="4">               
   </StackPanel>
</Border>

或者

<Border Background="#000000" BorderThickness="0" CornerRadius="4">
   <Border Background="#000000" BorderThickness="0" CornerRadius="4" Margin="4">
       <StackPanel>               
       </StackPanel>
    </Border>
</Border>

This indeed seems a bug in WPF. However for your specific case you can use two workarounds:

<Border Background="#000000" BorderThickness="0" CornerRadius="4">
   <StackPanel Margin="4">               
   </StackPanel>
</Border>

Or

<Border Background="#000000" BorderThickness="0" CornerRadius="4">
   <Border Background="#000000" BorderThickness="0" CornerRadius="4" Margin="4">
       <StackPanel>               
       </StackPanel>
    </Border>
</Border>
氛圍 2024-08-16 20:13:50

此行为是 WPF 工作方式所固有的。这不是一个错误。请注意,您的坐标都是双精度数,而不是整数:这些不是精确的单位。如果放大得足够大,您会看到错误。

以下内容来自大约一年前的记忆,但我认为是正确的:

如果您手动绘制到 wpf 渲染上下文,则可以使用“指南”系统使事物对齐。这就是为常用 UI 样式绘制按钮和事物的方式。查看参考源 (http://blogs.msdn.com/rscc/default.aspx)。 aspx),你可以自己看看。一般来说,关于这个主题还有一个很好的 msdn 页面:http://msdn。 microsoft.com/en-us/library/aa970908.aspx

This behavior is inherent in the way WPF works. It's not a bug. Note that your coordinates are all doubles, not integers: These are not precise units. If you zoom in enough, you will see errors.

The following is from memory from about a year ago, but I think it's right:

If you're drawing to the wpf rendering context by hand, you can use the 'guidelines' system to make things line up. This is how the buttons and things are drawn for the stock UI styles. Take a look at the reference source (http://blogs.msdn.com/rscc/default.aspx) and you can see for yourself. There's also a good msdn page on this subject in general: http://msdn.microsoft.com/en-us/library/aa970908.aspx

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