Question

Je cherche à créer un arrière-plan avec la partie supérieure de 48 pixels d'une couleur, et tout en dessous une autre couleur. J'ai créé un style, mais il se bloque au téléphone avec un « XamlParseException » lorsque je tente de l'utiliser.

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

Est-il possible de faire quelque chose comme ça en XAML, ou dois-je utiliser une image comme arrière-plan pour créer cet effet?

Était-ce utile?

La solution

Créer un rectangle dans la ligne 0, définissez sa propriété de remplissage. :) Rappelez-vous, vous pouvez couche choses en XAML.

Autres conseils

Vous pouvez définir votre arrière-plan pour un StackPanel avec Rectangles:

<Grid>
    <Grid.Background>
        <StackPanel>
            <Rectangle Height="48" Background="Green" />
            <Rectangle Background="Yellow" />
        </StackPanel>
    </Grid.Background>
</Grid>
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top