問題描述
我正在自學 WPF,但我似乎無法找到一種方法來完成這項工作.
I'm learning WPF on my own and I can't seem to find a way to make this work.
這是我的代碼:
<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>
如何使平鋪背景圖像出現?
How can I make a tiled background image appear?
推薦答案
或者,也許,您可以使用 視覺畫筆:
Or, perhaps, you could use 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 屬性設置基本圖塊的位置和尺寸.查看此處的示例.
The Viewport property sets the position and dimensions of the base tile. Have a look at examples here.
基本上,0,0,0.5,0.5"
意味著基礎圖塊將占用從點 (0,0) 到 (0.5,0.5) 的空間 - 即從左上角輸出區域的角落到中心.(1,1) 是右下角.您應該使用 MSDN Library.這真的很有用.所有的答案都在那里.
Basically, "0,0,0.5,0.5"
means that the base tile will take space from point (0,0) to (0.5,0.5) - i.e. from the upper left corner of the output area to centre. (1,1) is the lower right corner. You should make use of MSDN Library. It's really useful. All the answers are there.
這篇關于如何將 .PNG 圖像設置為我的 WPF 表單的 TILED 背景圖像?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!