I’m trying to reset the Background property of a button after I change it dynamically.
<Button Canvas.Left="-1" Canvas.Top="0" Content="a" FontFamily="Arial" Grid.Column="1" Height="60" Tag="a" Name="Ba" Width="60" FontWeight="Bold" FontSize="35" Foreground="Black">
<Button.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="White" Offset="0" />
<GradientStop Color="Black" Offset="1" />
<GradientStop Color="#FF757575" Offset="0.893" />
<GradientStop Color="#FF989898" Offset="0.074" />
</LinearGradientBrush>
</Button.Background>
</Button>
After I use the ClearValue method like so:
Ba.ClearValue(System.Windows.Controls.Button.BackgroundProperty);
I doesn’t quite go back to what is defined in the .xaml file. it looks similar, but not the same. Looks like some information is lost.
How can I, in some way, store all that information so it can be restored completely?
Thanks in advance,
Francisco Santiago
Define a Style, set the Background there and reapply it if you need it again.