wpf WPF重复图像背景
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13910867/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
WPF repeated image background
提问by 0070
i using C# and WPF building my project. In my application, i used a small size of image(25x25) as my application background. I found some example from the internet and when i try it, the background of my application is like imageA. But what i wish to do is like my background will be like the imageB. Any one know how to make it like the imageB?
我使用 C# 和 WPF 构建我的项目。在我的应用程序中,我使用了小尺寸的图像 (25x25) 作为我的应用程序背景。我从互联网上找到了一些示例,当我尝试时,我的应用程序的背景就像 imageA。但我想做的是我的背景就像 imageB 一样。有谁知道如何使它像imageB?
my WPF code snippet:
我的 WPF 代码片段:
<Grid>
<Grid.Background>
<VisualBrush TileMode="Tile" Viewport="0.8,0.8,0.1,0.1" AlignmentX="Left" AlignmentY="Top">
<VisualBrush.Visual>
<Image Source="/Wpf_Customer;component/bg.jpg"></Image>
</VisualBrush.Visual>
</VisualBrush>
</Grid.Background>
<RadioButton Content="Graph" Name="dsad" FontSize="15" ></RadioButton>
</Grid>
imageA:
图像A:


imageB:
图像B:


EDITED:
编辑:
imageC:
图像C:


回答by jimpanzer
Try it
尝试一下
<ImageBrush x:Key="SimpleBitmap" ImageSource="Assets\BitmapImage.png" TileMode="FlipY" Stretch="Uniform"AlignmentY="Top" Viewport="0,0,10,10" ViewportUnits="Absolute" />
Where BitmapImage Width = 10, and BitmapImage Height = 10
其中 BitmapImage Width = 10,BitmapImage Height = 10
回答by andrewpey
Did you try to set Stertchproperty of your image element to UniformToFill?
您是否尝试将Stertch图像元素的属性设置为UniformToFill?
UPDATE:Yeah, it was lame, my bad... Actually, you have no need to use VisualBrush, if I correctly understood your task. This should be enough:
更新:是的,它很蹩脚,我的错...实际上,如果我正确理解您的任务,您就不需要使用 VisualBrush。这应该足够了:
<Grid.Background>
<ImageBrush ImageSource="/Wpf_Customer;component/bg.jpg"/>
</Grid.Background>

