title: How do you assign the style programmatically
body: <p>I am trying to set one of my xaml styles to my frame in my page.
  It is created in code, and assigned to the layout dynamically. </p>
  
  <p>So I expect that I have to set the style dynamically? since the frame does not exist in xaml.</p>
  
  <p>What I cannot figure out, is how to assign a custom template. Or better yet, in a global manner to any frames that fit a certain category. Tag, or type etc.</p>
  
  <p>Below is my template that im trying to test with. But it does not work. Assume code is missing, so started checking codebehind style setting, but no luck so far.</p>
  
  <p><em>App.xaml</em></p>
  
  <pre><code>&lt;!-- http://paulstovell.com/blog/wpf-navigation --&gt;
  &lt;ControlTemplate TargetType="Frame" x:Key="frame" &gt;
      &lt;DockPanel Margin="7"&gt;
          &lt;StackPanel 
              Margin="7"
              Orientation="Horizontal"
              DockPanel.Dock="Top"
              &gt;
                  &lt;Button 
                  Content="Avast! Go back!" 
                  Command="{x:Static NavigationCommands.BrowseBack}" 
                  IsEnabled="{TemplateBinding CanGoBack}" 
                  /&gt;
                  &lt;Button 
                  Content="Forward you dogs!" 
                  Command="{x:Static NavigationCommands.BrowseForward}" 
                  IsEnabled="{TemplateBinding CanGoForward}" 
                  /&gt;
              &lt;/StackPanel&gt;
  
              &lt;Border 
              BorderBrush="Green"
              Margin="7"
              BorderThickness="7"
              Padding="7"
              CornerRadius="7"
              Background="White"
              &gt;
              &lt;ContentPresenter /&gt;
          &lt;/Border&gt;
      &lt;/DockPanel&gt;
  &lt;/ControlTemplate&gt;
  </code></pre>
  
  <p><em>MyWindow.xaml.cs</em></p>
  
  <pre><code> Frame newFrame = new Frame();
   newFrame.Content = content;
  
   newFrame.Template = ControlTemplate ...?
  </code></pre>