Ram*_*InX 5 c# wpf snapstodevicepixels
我element(StrokeThickness="1" SnapsToDevicePixels="True")
在Grid中使用Path .我想调整窗口大小,Grid元素由Viewbox元素包装.
问题
当我调整窗口大小时,Path会消失一段时间.如果我将SnapsToDevicePixels变为false,则Path元素可能会模糊,这不是我想要的.
如何避免单个像素线消失?
XAML代码:
<Window x:Class="WpfApplication2.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="207" Width="475">
<Viewbox Stretch="Fill">
<Grid Height="320" Width="517">
<Path Data="M0,0 H1 z" StrokeThickness="1" Stroke="Black" Margin="72,73,79,218" Stretch="Fill" SnapsToDevicePixels="True" MinHeight="1"/>
</Grid>
</Viewbox>
Run Code Online (Sandbox Code Playgroud)
可惜我没有声誉来发布运行时效果.
小智 0
我已经用放在视图框中的分隔符尝试了同样的问题。其中一些在某些分辨率下消失。为了解决这个问题,我将它们替换为高度为 1 像素的边框:
< Border Background="DarkGray" Grid.Row="0" Grid.ColumnSpan="7" Height="1" />
Run Code Online (Sandbox Code Playgroud)
这可以避免一个像素的单行在 viewBox 中消失。希望它对您也有用。
| 归档时间: |
|
| 查看次数: |
607 次 |
| 最近记录: |