我正在自己学习WPF,但我似乎找不到一种方法来实现这一点。
下面是我的代码:
<Window x:Class="Test.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Test" Height="600" Width="800" >
<DockPanel>
<Menu DockPanel.Dock="Right"
Height="30"
VerticalAlignment="Top"
Background="#2E404B"
BorderThickness="2.6">
<Menu.BitmapEffect>
<DropShadowBitmapEffect Direction="270" ShadowDepth="3" Color="#2B3841"/>
</Menu.BitmapEffect>
</Menu>
</DockPanel>
如何使平铺背景图像出现?
发布于 2009-11-13 05:14:46
或者,您可以使用Visual Brush
<Window
x:Class="Test.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Test" Height="600" Width="800">
<Window.Background>
<VisualBrush TileMode="Tile" Viewport="0,0,0.5,0.5">
<VisualBrush.Visual>
<Image Source="image.png"></Image>
</VisualBrush.Visual>
</VisualBrush>
</Window.Background>
</Window>
Viewport属性设置基本平铺的位置和尺寸。看看examples here吧。
基本上,"0,0,0.5,0.5"
意味着基础瓦片将占用从点(0,0)到(0.5,0.5)的空间-即从输出区域的左上角到中心。(1,1)是右下角。您应该使用MSDN Library。这真的很有用。所有的答案都在那里。
发布于 2011-06-29 16:55:15
将ViewportUnits设置为绝对,这将允许您在视口中定义图像的像素大小。在我的示例中,图像大小为32x32。
<Window.Background>
<ImageBrush ImageSource="image.png" TileMode="Tile" ViewportUnits="Absolute" Viewport="0,0,32,32"/>
</Window.Background>
https://stackoverflow.com/questions/1725184
复制相似问题