Reputation: 5487
I'm looking to create a background with the top 48 pixels one color, and everything below it another color. I've created a style, but it crashes the phone with a "XamlParseException" when I try to use it.
<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>
Is it possible to do something like this in xaml, or do I need to use an image as the background to create this effect?
Upvotes: 0
Views: 949
Reputation: 27717
You could set your background to be a StackPanel with Rectangles:
<Grid>
<Grid.Background>
<StackPanel>
<Rectangle Height="48" Background="Green" />
<Rectangle Background="Yellow" />
</StackPanel>
</Grid.Background>
</Grid>
Upvotes: 1
Reputation: 2767
Create a Rectangle in row 0, set its Fill property. :) Remember, you can layer things in XAML.
Upvotes: 2