I know this has been answered but with a more complex form. In this case it is a form with several grids and each one has its own styling resources I discovered the most efficient way to handle this involved two steps (mostly due to the fact that I forgot the adage "Scope matters"):
for accessibility give a name to the control holding the resources
Use the FindResource function of the control to set the child control
From the XAML
<Grid x:Name="grdJIT">
<Grid.Resources>
<ResourceDictionary>
<LinearGradientBrush x:Key="buttonStyleGradient" EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="White" Offset="0" />
<GradientStop Color="#FFACC3F5" Offset="1" />
</LinearGradientBrush>
<LinearGradientBrush x:Key="buttonStyleAlert" EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="Yellow" Offset="0" />
<GradientStop Color="#FFDD2375" Offset="1" />
</LinearGradientBrush>
</ResourceDictionary>
</Grid.Resources>
then in the Code behind (to set the background of a button called "btnGetRG")
LinearGradientBrush _r = (LinearGradientBrush)grdJIT.FindResource("buttonStyleAlert");
btnGetRG.Background = _r;
Like I said, the users question is answered previously and this is just a variant of that answer. I thought it worthwhile as my more specific search through Bing brought me here. Therefore, it seemed worth the post.