Hi, I just started Silverlight I built my first application to practice two-way binding and creating resources. Everything seems to work great except one thing.

I made a button that I would like to programmatically (in the c# code) change the gradient located in Application.Resources (simply switch their colors).

I attempt to do this with a function that handles the click event from that button as such:

Code:
private void changeGradient_Click(object sender, RoutedEventArgs e)
        {
            LinearGradientBrush brush =                   (LinearGradientBrush)this.Resources["BackgroundGradient"];

            Color color = brush.GradientStops[0].Color;
            brush.GradientStops[0].Color = brush.GradientStops[2].Color;
            brush.GradientStops[2].Color = color;

            
        }
However, instead of switching the colors the application screen just blanks out completely (just blank white screen) Can somebody please tell me what Im doing wrong?

Here is the Application.Resources code:
Code:
<Application.Resources>
        <LinearGradientBrush x:Key="BackgroundGradient">
            <LinearGradientBrush.GradientStops>
                <GradientStop Offset="0.00" Color="Green"/>
                <GradientStop Offset="0.50" Color="White"/>
                <GradientStop Offset="1.00" Color="Orange"/>
            </LinearGradientBrush.GradientStops>
        </LinearGradientBrush>
    </Application.Resources>
</Application>
And here is the XAML:
Code:
<Grid x:Name="LayoutRoot" Background="{StaticResource BackgroundGradient}">
        <StackPanel>
            <Slider x:Name="theslider" Margin=" 10, 15, 10, 10" Minimum="1" Maximum="40" Value="20"></Slider>
            <TextBlock VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Margin="10, 10, 10, 15"
                       x:Name="thetextblock" Text="Resize Me" FontFamily="Verdana" FontSize="{Binding ElementName= theslider, Path=Value, Mode=TwoWay}"></TextBlock>
            <Button VerticalAlignment="Top" HorizontalAlignment="Left" Margin="10,10,10,10" Width="70" Height="20" FontSize="8" x:Name="SmallText" Click="SmallText_Click" Content="Make Small"></Button>
            <Button VerticalAlignment="Top" HorizontalAlignment="Left" Margin="10,10,10,10" Width="70" Height="20" FontSize="8" x:Name="MediumText" Click="MediumText_Click" Content="Make Medium"></Button>
            <Button VerticalAlignment="Top" HorizontalAlignment="Left" Margin="10,10,10,10" Width="70" Height="20" FontSize="8" x:Name="BigText" Click="BigText_Click" Content="Make Big"></Button>
            <Button VerticalAlignment="Bottom" HorizontalAlignment="Left" Margin="10, 10, 10, 10" Width="80" Height="20" FontSize="8" x:Name="GradientChange" Click="changeGradient_Click" Content="Change Gradient"></Button>
            <TextBox VerticalAlignment="Top" HorizontalAlignment="Left" Margin="10, 10, 10, 10" Width="120" Height="30" Text="{Binding ElementName=thetextblock, Path=FontSize, Mode=TwoWay}"></TextBox>
        </StackPanel>
    </Grid>
Any help would be greatly appreciated.
Thanks