代码之家  ›  专栏  ›  技术社区  ›  CACuzcatlan

WP7是否可以在不使用图像的情况下使用双色背景?

  •  0
  • CACuzcatlan  · 技术社区  · 15 年前

    我正在寻找创建一个背景与前48像素的一种颜色,而下面的一切另一种颜色。我已经创建了一个样式,但当我尝试使用它时,它会以“XamlParseException”崩溃手机。

            <Style x:Key="BackgroundStyle" TargetType="Grid">
                <Setter Property="Background">
                    <Setter.Value>
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="48" />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>
                            <Grid Grid.Row="0" Background="Green" />
                            <Grid Grid.Row="1" Background="Yellow" />
                        </Grid>
                    </Setter.Value>
                </Setter>
            </Style>
    

    2 回复  |  直到 15 年前
        1
  •  2
  •   Curt Nichols    15 年前

    在第0行中创建矩形,设置其填充属性。:)记住,可以用XAML来分层。

        2
  •  1
  •   Jake Pearson    15 年前

    您可以将背景设置为带有矩形的StackPanel:

    <Grid>
        <Grid.Background>
            <StackPanel>
                <Rectangle Height="48" Background="Green" />
                <Rectangle Background="Yellow" />
            </StackPanel>
        </Grid.Background>
    </Grid>
    
    推荐文章