网格背景图像和颜色 [英] Grid with background image and color
问题描述
是否有可能给整个电网在XAML既是一个背景图像和颜色?所以有不具有一个颜色区域我不缩放图像。是否有可能颜色网格的休息颜色?
这是我目前的code:
<网格和GT;
< Grid.Background>
<的ImageBrush拉伸=无的ImageSource =图像/ background_top.pngAlignmentY =评出的AlignmentX =中心/>
< /Grid.Background> < Grid.RowDefinitions>
< RowDefinition HEIGHT =50 */>
< RowDefinition HEIGHT =50 */>
< /Grid.RowDefinitions>
< /网格和GT;
这是我能想到的唯一方法是使用背景属性来设置颜色,然后添加一个图像到网格确保跨越所有的行和列。只要图像是在你的网格中的第一个项目的其他人将在顶部分层。我beleive它会给你你正在寻找的效果。
<网格背景=红>
<图像Grid.RowSpan =2弹力=无源=图像/ background_top.pngVerticalAlignment =顶部的HorizontalAlignment =中心/>
<标签内容=标签Grid.Row =0HEIGHT =28的HorizontalAlignment =中心保证金=10,10,0,0NAME =LABEL1VerticalAlignment =顶部/>
< Grid.RowDefinitions>
< RowDefinition HEIGHT =50 */>
< RowDefinition HEIGHT =50 */>
< /Grid.RowDefinitions>
< /网格和GT;
Is it possible to give an entire grid in xaml both a background image and a color? I am not scaling the image so there are regions that do not have a color. Is it possible to color the rest of the grid in a color?
This is my current code:
<Grid>
<Grid.Background>
<ImageBrush Stretch="None" ImageSource="Images/background_top.png" AlignmentY="Top" AlignmentX="Center"/>
</Grid.Background>
<Grid.RowDefinitions>
<RowDefinition Height="50*" />
<RowDefinition Height="50*" />
</Grid.RowDefinitions>
</Grid>
The only way that I can think of is to use the Background Property to set the Color, then add an Image to the Grid making sure to span all of your Rows and Columns. As long as the Image is the first Item in your grid the others will be layered on top. I beleive it will give you the effect you are looking for.
<Grid Background="Red">
<Image Grid.RowSpan="2" Stretch="None" Source="Images/background_top.png" VerticalAlignment="Top" HorizontalAlignment="Center"/>
<Label Content="Label" Grid.Row="0" Height="28" HorizontalAlignment="Center" Margin="10,10,0,0" Name="label1" VerticalAlignment="Top" />
<Grid.RowDefinitions>
<RowDefinition Height="50*" />
<RowDefinition Height="50*" />
</Grid.RowDefinitions>
</Grid>
这篇关于网格背景图像和颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!