title: Dynamically update style of control in UWP via a trigger
body: <p>I want to display the <code>style</code> of a control in a template depending on an <code>enum</code> in the used class. I tried to use <a href="https://stackoverflow.com/questions/14279602/how-can-i-use-enum-types-in-xaml">this to use the enum in XAML</a> and <a href="https://stackoverflow.com/questions/33648456/uwp-style-trigger-missing">this to create a trigger</a>. The problem is that I cannot use <code>x:Static</code> in UWP and the trigger is never fired. My workaround does not work either.</p>
  <p>My class:</p>
  <pre class="lang-cs prettyprint-override"><code>
  //Namespace Enums
  public enum ConnectionState
  {
      Open,
      Closed,
      Connecting,
      Broken
  }
  
  //Namespace Models
  public class DatabaseConnection : INotifyPropertyChanged
  {
      public event PropertyChangedEventHandler PropertyChanged;
      private void OnPropertyChanged([CallerMemberName] string propertyName = &quot;&quot;)
      {
          PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
      }
  
      private ConnectionState _connectionState = ConnectionState.Broken;
      public ConnectionState ConnState
      {
          get =&gt; _connectionState;
          set
          {
              if (value != _connectionState)
              {
                  _connectionState = value;
                  OnPropertyChanged();
                  OnPropertyChanged(nameof(ConnStateInt));
                  OnPropertyChanged(nameof(InfoBadgeStyle));
              }
          }
      }
  
      public int ConnStateInt =&gt; (int)ConnState;
  
      public Style InfoBadgeStyle
      {
          get
          {
              return ConnState switch
              {
                  ConnectionState.Open =&gt; (Style)Application.Current.Resources[&quot;SuccessIconInfoBadgeStyle&quot;],
                  ConnectionState.Connecting =&gt; (Style)Application.Current.Resources[&quot;AttentionIconInfoBadgeStyle&quot;],
                  ConnectionState.Broken =&gt; (Style)Application.Current.Resources[&quot;CriticalIconInfoBadgeStyle&quot;],
                  _ =&gt; (Style)Application.Current.Resources[&quot;InformationalIconInfoBadgeStyle&quot;],
              };
          }
      }
  }
  </code></pre>
  <p>My template:</p>
  <pre class="lang-xml prettyprint-override"><code>&lt;Page.Resources&gt;
      &lt;DataTemplate x:Key=&quot;ConnectionTemplate&quot; x:DataType=&quot;models:DatabaseConnection&quot;&gt;
          &lt;muxc:InfoBadge Style=&quot;{x:Bind InfoBadgeStyle}&quot;/&gt;
      &lt;/DataTemplate&gt;
  &lt;/Page.Resources&gt;
  </code></pre>
  <p>How can I update the style with a trigger in UWP?</p>