Can <Setter.Value> have multiple grids inside it
Posted
by Subhen
on Stack Overflow
See other posts from Stack Overflow
or by Subhen
Published on 2010-05-13T05:48:14Z
Indexed on
2010/05/13
5:54 UTC
Read the original article
Hit count: 138
Hi, I want to define the background for my application in App.XAML. The background was previously defined in another xaml page,which have multiple Grids inside it like following:
<Grid x:Key="GridGeneric" d:LayoutOverrides="Width, Height">
<Grid.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FF00172E" Offset="1"/>
<GradientStop Color="#FF004074" Offset="0.433"/>
<GradientStop Color="#FF081316"/>
<GradientStop Color="#FF001D3F" Offset="0.215"/>
<GradientStop Color="#FF002043" Offset="0.818"/>
<GradientStop Color="#FF003B6C" Offset="0.642"/>
</LinearGradientBrush>
</Grid.Background>
<Grid>
<Grid.Background>
<RadialGradientBrush RadiusY="0.973" GradientOrigin="0.497,-0.276" RadiusX="1.003">
<GradientStop Color="#FFB350EE" Offset="0"/>
<GradientStop Color="#001D3037" Offset="0.847"/>
</RadialGradientBrush>
</Grid.Background>
</Grid>
------
-----
</Grid>
Now I want to place the same in my App.xaml like following:
<Style x:Key="backgroundStyle" TargetType="Grid">
<Setter Property="Background">
<Setter.Value>
<Grid>
<Grid.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FF00172E" Offset="1"/>
<GradientStop Color="#FF004074" Offset="0.433"/>
<GradientStop Color="#FF081316"/>
<GradientStop Color="#FF001D3F" Offset="0.215"/>
<GradientStop Color="#FF002043" Offset="0.818"/>
<GradientStop Color="#FF003B6C" Offset="0.642"/>
</LinearGradientBrush>
</Grid.Background>
<Grid>
<Grid.Background>
<RadialGradientBrush RadiusY="0.973" GradientOrigin="0.497,-0.276" RadiusX="1.003">
<GradientStop Color="#FFB350EE" Offset="0"/>
<GradientStop Color="#001D3037" Offset="0.847"/>
</RadialGradientBrush>
</Grid.Background>
</Grid>
---------
---------
</Grid>
</Setter.Value>
</Setter>
</Style>
But While doing this I am getting the following Exception.
© Stack Overflow or respective owner