title: Bindind resources control with content control WPF
body: <p>I've just started learning WPF. However, now I'm having issues with my UI (which remains empty). This is the code I'm using; What I'm trying to do is to display the properties of the <code>River</code> in the UI.</p>
  
  <pre><code>&lt;Window.Resources&gt;
      &lt;local:River x:Key="theRiver" Name="Colorado River" MilesLong="1450" /&gt;
      &lt;StackPanel x:Key="stackey" DataContext="theRiver"&gt;
          &lt;StackPanel.Resources&gt;
              &lt;DataTemplate x:Key="key" DataType="{x:Type local:River}" &gt;
                  &lt;Border x:Name="bdr" BorderBrush="Blue" BorderThickness="3" CornerRadius="12" Padding="2"&gt;
                      &lt;Grid Margin="5"&gt;
                          &lt;TextBlock x:Name="txt" FontFamily="Bookman old style"&gt;
                              &lt;Run Text="The"/&gt;
                              &lt;TextBlock Text="{Binding Name}"/&gt;
                              &lt;Run Text="is"/&gt;
                              &lt;TextBlock Text="{Binding MilesLong}" /&gt;
                              &lt;Run Text="miles long." /&gt;
                          &lt;/TextBlock&gt;
                      &lt;/Grid&gt;
                  &lt;/Border&gt;
                  &lt;DataTemplate.Triggers&gt;
                      &lt;Trigger SourceName="bdr" Property="IsMouseOver" Value="True"&gt;
                          &lt;Setter TargetName="bdr" Property="Background" Value="Red"/&gt;
                          &lt;Setter TargetName="txt" Property="Foreground" Value="Green"/&gt;
                          &lt;Setter TargetName="bdr" Property="CornerRadius" Value="40"/&gt;
                      &lt;/Trigger&gt;
                  &lt;/DataTemplate.Triggers&gt;
              &lt;/DataTemplate&gt;
          &lt;/StackPanel.Resources&gt;
      &lt;/StackPanel&gt;
  &lt;/Window.Resources&gt;
  &lt;Grid&gt;
      &lt;Grid.ColumnDefinitions&gt;
          &lt;ColumnDefinition /&gt;
          &lt;ColumnDefinition/&gt;
      &lt;/Grid.ColumnDefinitions&gt;
      &lt;!--&lt;StackPanel Grid.Column="1" Grid.Row="1" Margin="10" Background="Gold" DataContext="{StaticResource theRiver}&gt;--&gt;
      &lt;ContentControl Content="{StaticResource ResourceKey=stackey}"  Grid.Column="1" Grid.Row="1" Margin="10" Background="Gold" /&gt;
  &lt;/Grid&gt;
  </code></pre>