WPF显示图像,为什么会出现误差?

njypgzz 2012-03-18 11:04:24
例如:我的Image大小设定为20*20像素,但是,运行显示的时候,Image却变为:20*21像素了。

为什么会这样?

是什么原因带来了控件大小的误差?
...全文
121 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
macooidle 2012-03-19
  • 打赏
  • 举报
回复
你print的?
njypgzz 2012-03-18
  • 打赏
  • 举报
回复
发现不只是Image控件会这样,如Button等其他控件,都有可能出现这种情况。。。
Kation 2012-03-18
  • 打赏
  • 举报
回复
你怎么确定范围的?
njypgzz 2012-03-18
  • 打赏
  • 举报
回复
没有用ViewBox。发现,任何控件,都会有一个像素的误差。这是什么原因?

就简单的代码如下:
最终运行时,Boder在屏幕上显示却是21*20像素。


<Window x:Class="Test.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow">


<Grid>
<Border Width="20" Height="20" Background="Green" BorderThickness="0" BorderBrush="Transparent"></Border>
</Grid>

</Window>


[Quote=引用 2 楼 macooidle 的回复:]

你用viewbox了?
[/Quote]
macooidle 2012-03-18
  • 打赏
  • 举报
回复
你用viewbox了?

111,126

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧