2013-12-12 185 views
0

我需要将图像设置为WPF窗口的背景。我已经将它设置这样的:将图像的高度和宽度设置为WPF背景

<Window x:Class="DiagramView" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     Height="418" Width="1185" ResizeMode="NoResize" WindowStartupLocation="CenterScreen"> 
    <Window.Background> 
     <ImageBrush ImageSource="../Images/Med.jpg" ></ImageBrush> 
    </Window.Background> 
</Window> 

但如果我有高度和宽度的窗口,原单的图像,在窗口中的图像是不是不削理所应当的。我想这是因为窗户本身占据了高度和宽度的一部分。我的属性我应该使用与原单宽度/高度

回答

1

图像,以便保留原始图像尺寸设置Stretch属性为None

<Window.Background> 
    <ImageBrush ImageSource="../Images/Med.jpg" Stretch="None" /> 
</Window.Background> 
0

如果你看看ImageBrush Class页面上MSDN上,您会看到有很多属性可用于将图像放置在Brush之内。以下是特别感兴趣的定位:

AlignmentX
AlignmentY
弹力
Viewbox控件
ViewboxUnits
视窗
ViewportUnits

请查看链接页面及其说明。

相关问题