title: How can you retrieve a Brush from a ResourceDictionary defined in XAML and apply it to an element in code?
body: <pre><code>&lt;ResourceDictionary
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"&gt;
  
      &lt;LinearGradientBrush x:Key="ButtonNormalBackgroundBrush"
          StartPoint = "0.5,0"
          EndPoint   = "0.5,1"&gt;
  
          &lt;GradientStop Color="#C10099FF" Offset="0"/&gt;
          &lt;GradientStop Color="#C16699CC" Offset="1"/&gt;
          &lt;GradientStop Color="#C1006699" Offset="0.49"/&gt;
  
      &lt;/LinearGradientBrush&gt;
  
  &lt;ResourceDictionary/&gt;
  </code></pre>
  
  <p>Now i want to get LinearGradientBrush from ResourceDictonary and apply it dynamically  to a button as background color in wpf.</p>
  
  <pre><code> BtnGetBrushes.Background = Brushes.Green;
  </code></pre>
  
  <p>I want to apply the above color instead of this(Brushes.Green). what should i do for that ?</p>