我正在尝试使用给定的布局创建一个窗口,我很好奇最好的方法。我已将窗口背景设置为较浅颜色的平铺图像。然后我想我会添加一个带有五列和一行的uniformgrid,第五列具有“橙色”略微透明的背景。然后我会添加另一个统一网格,其中包含5行和1列,第2行和第2行。 3具有相同的“橙色”颜色设置。最后,我会在左上角添加一个公司徽标,在“橙色”的水平带中添加一些文本。我的方法似乎不起作用:-(任何指导,因为我自己对此进行调查将非常感激。
答案 0 :(得分:2)
这对我很有用:
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="5*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid Grid.Row="0" Grid.Column="0" Background="Yellow">
<Image Source="http://www.google.com/images/srpr/logo3w.png"
HorizontalAlignment="Left"/>
</Grid>
<Grid Grid.Row="0" Grid.Column="1" Background="Orange"/>
<Grid Grid.Row="1" Grid.Column="0" Background="Orange"/>
<Grid Grid.Row="1" Grid.Column="1" Background="Red"/>
<Grid Grid.Row="2" Grid.Column="0" Background="Yellow"/>
<Grid Grid.Row="2" Grid.Column="1" Background="Orange"/>
<TextBlock Grid.Row="1" Grid.ColumnSpan="2" Grid.Column="0">
I am nice text spanning the whole row! Look, here's a lot
of me in the cell.
</TextBlock>
</Grid>
</Page>
如果你坚持使用半透明条纹,你可以制作类似
的东西<Grid Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="1"
Background="Orange" Opacity="0.5"/>
或
<Grid Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="1" Background="#80FF7F00"/>
(包括不透明度的颜色)等。
例如,试试这个(你需要调整颜色):
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="5*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2"
Background="Yellow" Opacity="0.5"/>
<Grid Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2"
Background="Orange" Opacity="0.5"/>
<Grid Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2"
Background="Yellow" Opacity="0.5"/>
<Grid Grid.Row="0" Grid.Column="0" Grid.RowSpan="3"
Background="Yellow" Opacity="0.5"/>
<Grid Grid.Row="0" Grid.Column="1" Grid.RowSpan="3"
Background="Orange" Opacity="0.5"/>
<Image Grid.Row="0" Grid.Column="0"
Source="http://www.google.com/images/srpr/logo3w.png"
HorizontalAlignment="Left"/>
<TextBlock Grid.Row="1" Grid.ColumnSpan="2" Grid.Column="0">
I am nice text spanning the whole row! Look, here's a lot
of me in the cell.
</TextBlock>
</Grid>
</Page>
答案 1 :(得分:1)
简短的回答就是使用网格并将细胞的背景颜色设置为我选择的颜色,并略微透明。然后,我可以将交叉的单元格设置为较暗的颜色,或者为相交的单元格添加标签,并使用相同的背景和透明度。感谢大家的帮助。在过去的一个小时里,我学到了很多关于xaml和WPF的知识。