WPF 中 WindowStyle=“None”的 Label 附近出现一条奇怪的鬼线
这是代码:
<Window x:Class="WpfWindow.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" mc:Ignorable="d" Topmost="True" WindowStyle="None" ResizeMode="NoResize"
d:DesignHeight="300" d:DesignWidth="300" SizeToContent="WidthAndHeight" WindowStartupLocation="CenterScreen">
<Label Content="Test label" />
</Window>
它生成以下图像:
只要以下参数,它似乎就会不断重现set:
- ResizeMode = "NoResize"
- WindowStyle = "None"
- SizeToContent = "WidthAndHeight"
我希望如果我为窗口设置边框颜色,它会消失,但是,即使我这样做,它也会保留在那里......
任何人都有想法我怎样才能让这条线消失?
谢谢!
Here is the code:
<Window x:Class="WpfWindow.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" mc:Ignorable="d" Topmost="True" WindowStyle="None" ResizeMode="NoResize"
d:DesignHeight="300" d:DesignWidth="300" SizeToContent="WidthAndHeight" WindowStartupLocation="CenterScreen">
<Label Content="Test label" />
</Window>
It produces the following image:
It seems to reproduce constantly with as long as the following parameters are set:
- ResizeMode = "NoResize"
- WindowStyle = "None"
- SizeToContent = "WidthAndHeight"
I hoped it'd disappear if I set a border color for the window, however, it stays there even if I do that...
Anyone has an idea of how I can make this line disappear?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将 SnapsToDevicePixels="True" 添加到窗口属性。
我想你在这里看到的是窗户背景后面的一小片黑色。如果将背景颜色设置为透明,您可以看到完整的黑色。
Add
SnapsToDevicePixels="True"
to the window properties.What I think you are seeing here is a sliver of the black behind the window background. You can see this black in full if you set the Background color to Transparent.