title: Parse Exception occurring due to my Styling
body: <p>I am creating a WPF application in C# using XAML. I have looked into the <a href="https://docs.microsoft.com/en-us/windows/apps/design/style/xaml-styles" rel="nofollow noreferrer">documentation of creating Styles for XAML</a>.</p>
  <p>It looks to be working correctly in the Designer before I actually run my application. Upon running my application I receive a parse exception. Looking at the line and position indicated, <code>&lt;Style=&quot;{StaticResource T}&quot; /&gt;</code> is the cause of this error. Removing it solves the issue, but this requires me to do an inline <code>Style</code> which I would like to avoid.</p>
  <p>The XAML code for the <code>Page</code> encountering this issue is below and I would appreciate any feedback and guidance on this issue. The Style not working here is the <code>x:Key=&quot;T&quot; TargetType=&quot;Border&quot;</code>.</p>
  <pre><code>&lt;Page x:Class=&quot;NGClient1.Screen1.BE2.WindowBe2Tablet&quot;
        xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
        xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;
        xmlns:mc=&quot;http://schemas.openxmlformats.org/markup-compatibility/2006&quot; 
        xmlns:d=&quot;http://schemas.microsoft.com/expression/blend/2008&quot; 
        xmlns:local=&quot;clr-namespace:NGClient1.Screen1.BE2&quot;
        mc:Ignorable=&quot;d&quot; 
        d:DesignHeight=&quot;450&quot; d:DesignWidth=&quot;800&quot;
        Title=&quot;WindowBe2Tablet&quot; Width=&quot;1024&quot; Height=&quot;1280&quot; Background=&quot;Black&quot;&gt;
  
      &lt;Grid&gt;
  
          &lt;Grid&gt;
              &lt;Grid.ColumnDefinitions &gt;
                  &lt;ColumnDefinition Width=&quot;*&quot;/&gt;
                  &lt;ColumnDefinition Width=&quot;*&quot;/&gt;
              &lt;/Grid.ColumnDefinitions&gt;
  
              &lt;Grid.RowDefinitions&gt;
                  &lt;RowDefinition Height=&quot;*&quot;/&gt;
                  &lt;RowDefinition Height=&quot;*&quot;/&gt;
                  &lt;RowDefinition Height=&quot;*&quot;/&gt;
              &lt;/Grid.RowDefinitions&gt;
  
              &lt;Image Source=&quot;Resources/backdrop.png&quot; Stretch=&quot;UniformToFill&quot; Grid.ColumnSpan=&quot;2&quot; Grid.RowSpan=&quot;3&quot; /&gt;
  
              &lt;StackPanel Grid.Column=&quot;0&quot; Grid.Row=&quot;0&quot; Grid.ColumnSpan=&quot;2&quot; Grid.RowSpan=&quot;2&quot; VerticalAlignment=&quot;Center&quot; HorizontalAlignment=&quot;Center&quot;&gt;
                  &lt;TextBlock Text=&quot;Advert Section Here&quot; /&gt;
              &lt;/StackPanel&gt;
  
              &lt;Border Grid.Column=&quot;0&quot; Grid.Row=&quot;2&quot; Grid.ColumnSpan=&quot;2&quot; BorderBrush=&quot;White&quot; BorderThickness=&quot;4&quot; Background=&quot;Black&quot; Margin=&quot;40, 40, 40, 40&quot; Opacity=&quot;0.5&quot;/&gt; --&gt;
              &lt;Border Grid.Column=&quot;0&quot; Grid.Row=&quot;2&quot; Grid.ColumnSpan=&quot;2&quot; Style=&quot;{StaticResource T}&quot; /&gt; &lt;!-- Exception being thrown here, unsure why --&gt;
              
              &lt;StackPanel Grid.Column=&quot;0&quot; Grid.Row=&quot;2&quot; VerticalAlignment=&quot;Center&quot; HorizontalAlignment=&quot;Center&quot;&gt;
                  &lt;TextBlock Text=&quot;Lower Section Left Here&quot; /&gt;
              &lt;/StackPanel&gt;
  
              &lt;StackPanel Grid.Column=&quot;1&quot; Grid.Row=&quot;2&quot; VerticalAlignment=&quot;Center&quot; HorizontalAlignment=&quot;Center&quot;&gt;
                  &lt;TextBlock Text=&quot;Lower Section Right Here&quot; /&gt;
              &lt;/StackPanel&gt;
  
          &lt;/Grid&gt;
      &lt;/Grid&gt;
  
      &lt;Page.Resources&gt;
      
          &lt;Style x:Key=&quot;T&quot; TargetType=&quot;Border&quot; &gt; &lt;!-- x:Key causing exception, unsure why --&gt;
              
              &lt;Setter Property=&quot;BorderBrush&quot; Value=&quot;White&quot;/&gt;
              &lt;Setter Property=&quot;BorderThickness&quot; Value=&quot;4&quot;/&gt;
              &lt;Setter Property=&quot;Background&quot; Value=&quot;Black&quot;/&gt;
              &lt;Setter Property=&quot;Margin&quot; Value=&quot;40, 40, 40, 40&quot;/&gt;
              &lt;Setter Property=&quot;Opacity&quot; Value=&quot;0.5&quot;/&gt;
              
          &lt;/Style&gt;
  
          &lt;Style TargetType=&quot;TextBlock&quot;&gt;
              
              &lt;Setter Property=&quot;Foreground&quot; Value=&quot;White&quot;/&gt;
              &lt;Setter Property=&quot;FontSize&quot; Value=&quot;25&quot;/&gt;
              &lt;Setter Property=&quot;HorizontalAlignment&quot; Value=&quot;Center&quot;/&gt;
              &lt;Setter Property=&quot;VerticalAlignment&quot; Value=&quot;Center&quot;/&gt;
              
          &lt;/Style&gt;
          
      &lt;/Page.Resources&gt;
  &lt;/Page&gt;
  </code></pre>