我想实验我的WPF应用程序的图像背景。我下载了一些纹理,但不幸的是我有一个问题。 这里是我的XAML:平铺背景 - 瓦片之间的黑色空间
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="458" Width="473">
<Window.Background>
<VisualBrush TileMode="Tile" Viewport="0,0,0.5,0.5" Stretch="None">
<VisualBrush.Visual>
<Image Source="Images/binding_dark.png" Stretch="None">
<Image.OpacityMask>
<ImageBrush ImageSource="Images/binding_dark.png" Stretch="None" TileMode="Tile"/>
</Image.OpacityMask>
</Image>
</VisualBrush.Visual>
</VisualBrush>
</Window.Background>
<Grid>
</Grid>
</Window>
这只是一个空的窗口,但是这只是看到更好的问题是什么。 这里的结果:
我想获得一个不错的质感为我的应用程序的背景,但由于某种原因,图像不相互对齐 - 他们之间有这个奇怪的黑色间隔。这是什么原因?
//编辑 只是为了澄清: 我想有许多建在同一图像的平铺副本的背景 - 不是一个imgage填充整个窗口
我想你的代码,但它不是我想要得到的结果。我的图像分辨率相当低。我希望有一种相互显示的图像。我不想让一张图片填满整个窗口 - 这种方式看起来像素化。 – Loreno
我也尝试将图片的TileMode设置为“平铺”,但它不会更改任何内容 – Loreno
@Loreno,嗯,有趣,请检查您的图片。它没有透明边框吗?我敢打赌这是一个PNG – Alex