如何在WPF(overlay uniformgrid?)中进行布局

如何在WPF(overlay uniformgrid?)中进行布局,wpf,layout,Wpf,Layout,我正在尝试用给定的布局创建一个窗口,我对最好的方法很好奇。我已将窗口背景设置为浅色的平铺图像。然后我想我应该添加一个uniformgrid,它有五列,一行,第五列有一个“橙色”的稍微透明的背景。然后,我将添加另一个具有5行和1列的统一网格,其中第2行和第3行具有相同的“橙色”颜色设置。最后,我将在左上角添加一个公司徽标,并在“橙色”水平带中添加一些文字。我的方法似乎不起作用:-(我自己正在研究的任何指导都将不胜感激。这对我很有效: <Page xmlns="http://schemas.m

我正在尝试用给定的布局创建一个窗口,我对最好的方法很好奇。我已将窗口背景设置为浅色的平铺图像。然后我想我应该添加一个uniformgrid,它有五列,一行,第五列有一个“橙色”的稍微透明的背景。然后,我将添加另一个具有5行和1列的统一网格,其中第2行和第3行具有相同的“橙色”颜色设置。最后,我将在左上角添加一个公司徽标,并在“橙色”水平带中添加一些文字。我的方法似乎不起作用:-(我自己正在研究的任何指导都将不胜感激。

这对我很有效:

<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"/>


(包括颜色的不透明度)等

例如,试试这个(你需要调整颜色):


我是一条横跨整行的漂亮文字!看,这里有很多
我在牢房里。

简单的答案是使用网格,将单元格的背景色设置为我选择的颜色,并带有一点透明度。然后,我可以将相交单元格设置为较暗的颜色,或者为具有相同背景和透明度的相交单元格添加标签。感谢大家的帮助。在过去的一个小时里,我您已经了解了很多关于xaml和WPF的知识。

为什么不使用2x3网格呢?您可以使用
Width=“5*”
Width=“1*”
是的,这可能会起作用……然后我会手动设置相交单元格的颜色。我以前使用过一个网格,其中行/列维度设置为星号值,填充了用户控件以保存内容。请看这里:
<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>