title: Set Grid background color programmatically in Silverlight
body: <p>I have a Data template</p>
  
  <pre><code>&lt;DataTemplate x:Key="ConnectorItemFactory"&gt;
      &lt;Button Style="{StaticResource TextOnlyActionTileButtonStyle}" Margin="0,0,5,0"
                  HorizontalAlignment="Stretch"
                  VerticalAlignment="Stretch"
                  HorizontalContentAlignment="Stretch"
                  VerticalContentAlignment="Stretch"
                  Content="{Binding}"
                  ContentTemplate="{StaticResource TileTemplate}"
                  Command="{StaticResource NavigationCommand}"
                  CommandParameter="{Binding}"
          Height="156"
          Width="156"
          &gt;
        &lt;i:Interaction.Behaviors&gt;
          &lt;UICommon:XboxBehavior VuiBinding="{Binding VuiTitle}"/&gt;
        &lt;/i:Interaction.Behaviors&gt;
      &lt;/Button&gt;
    &lt;/DataTemplate&gt;
  </code></pre>
  
  <p>as a ContentTemplate it is used another data template</p>
  
  <pre><code>&lt;DataTemplate x:Key="TileTemplate"&gt;
    &lt;Grid VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Background="{StaticResource ActionButtonBackgroundBrush}"&gt;
      &lt;StackPanel Orientation="Vertical" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="7,7,7,4"&gt;
        &lt;Controls:TrimmedTextBlock Text="{Binding Title}" Style="{StaticResource TextOnlyTileTitleStyle}" TextWrapping="Wrap" /&gt;
        &lt;Controls:TrimmedTextBlock Text="{Binding Converter={StaticResource SubtitleTextFormatter}}" Style="{StaticResource TextOnlyTileSubtitleStyle}"/&gt;
      &lt;/StackPanel&gt;
    &lt;/Grid&gt;
  &lt;/DataTemplate&gt;
  </code></pre>
  
  <p>I'm using a TemplateFactory to load the content template</p>
  
  <pre><code> public class GridTemplateFactory : ModelViewTemplateFactory
          {
              protected override void OnContentChanged(object oldContent, object newContent)
              {
                  base.OnContentChanged(oldContent, newContent);
  
                  var dataTemplate = Application.Current.Resources["ConnectorItemFactory"] as DataTemplate;
  
                  // var grid = ((Button)dataTemplate.LoadContent()).ContentTemplate.LoadContent();
                  // ((Grid)grid).Background = new SolidColorBrush(Colors.Orange);
  
                  // ((Button)dataTemplate.LoadContent()).ContentTemplate.LoadContent().SetValue(Grid.BackgroundProperty, new SolidColorBrush(Colors.Orange));
  
  
                  this.ContentTemplate = dataTemplate;
              }
          }
  </code></pre>
  
  <p>In the OnContentChanged method I want to change the Grid background color from the TileTemplate data template.
  I tried to do it like in commented code above, but it doesn't work. How can I change the color here? </p>