title: How to use VisualStateManager instead of DataTrigger to implement dynamic binding?
body: <p>I've tried to implement DataTrigger, to perform dynamic binding based on which toggle button is toggled in a View. But after searching on the issue, <a href="https://stackoverflow.com/questions/7439532/datatrigger-in-winrt">DataTrigger in WinRT?</a> it seems this is not available in Windows Universal apps, and VisualStateManager  should be used instead.</p>
  
  <p>My question is, how can I implement the equivalent of the below code using the VisualStateManager? Or any other alternative to set the dynamic binding from the properties in code behind of the View Model.</p>
  
  <p>This is the XAML I had intended to use until I ran into this problem, where the default binding is <code>OrdinaryGradePointKV</code> and when the toggle button is toggle the binding is changed to <code>HigherGradePointKV</code>:</p>
  
  <pre><code>&lt;ComboBox
       Grid.Row="1"
       Grid.Column="0"
       Grid.ColumnSpan="2"
       Width="60"
       HorizontalAlignment="Right"
       DisplayMemberPath="Key"&gt;
       &lt;ComboBox.Style&gt;
           &lt;Style&gt;
               &lt;Setter Property="ComboBox.ItemsSource" Value="{Binding OrdinaryGradePointKV}"&gt;&lt;/Setter&gt;
               &lt;Style.Triggers&gt;
                   &lt;DataTrigger Binding="{Binding IsHigherToggled}" Value="True"&gt;
                       &lt;Setter Property="ComboBox.ItemsSource"
                           Value="{Binding HigherGradePointKV}" /&gt;
                   &lt;/DataTrigger&gt;
               &lt;/Style.Triggers&gt;
           &lt;/Style&gt;
       &lt;/ComboBox.Style&gt;
   &lt;/ComboBox&gt;
  </code></pre>
  
  <p>A trimmed down version of the VM is as follows, showing the properties that are being bound:</p>
  
  <pre><code>namespace LC_Points.ViewModel
  {
  
      public class MainViewModel : ViewModelBase
      {
  
          /// &lt;summary&gt;
          /// Initializes a new instance of the MainViewModel class.
          /// &lt;/summary&gt;
          public MainViewModel()
          {
              //call methods to initialize list data
              GetSubjectTypes();
              GetOrdinaryGradePairs();
              GetHigherGradePairs();
          }
  
  
          public List&lt;Score&gt; Subjects { get; set; }
          public List&lt;StringKeyValue&gt; HigherGradePointKV { get; set; }
          public List&lt;StringKeyValue&gt; OrdinaryGradePointKV { get; set; }
  
  
          //ordinary toggle button bool
          private bool _isOrdinaryToggled;
          public bool IsOrdinaryToggled
          {
              get
              {
                  return _isOrdinaryToggled;
              }
              set
              {
                  _isOrdinaryToggled = value;
                  RaisePropertyChanged("IsOrdinaryToggled");
              }
          }
  
          //Higher toggle button bool property
          private bool _isHigherToggled;
          public bool IsHigherToggled
          {
              get
              {
                  return _isHigherToggled;
              }
              set
              {
                  _isHigherToggled = value;
                  RaisePropertyChanged("IsHigherToggled");
              }
          }
  
  
  
  
          public class StringKeyValue
          {
              public string Key { get; set; }
              public int Value { get; set; }
          }
  
  
          public void GetOrdinaryGradePairs()
          {
  
              List&lt;StringKeyValue&gt; ordianryGradePointKVTemp = new List&lt;StringKeyValue&gt;();
  
  
              ordianryGradePointKVTemp.Add(new StringKeyValue { Key = "A1", Value = 60 });
              ordianryGradePointKVTemp.Add(new StringKeyValue { Key = "A2", Value = 50 });
              ordianryGradePointKVTemp.Add(new StringKeyValue { Key = "B1", Value = 45 });
              ordianryGradePointKVTemp.Add(new StringKeyValue { Key = "B2", Value = 40 });
              ordianryGradePointKVTemp.Add(new StringKeyValue { Key = "B3", Value = 35 });
              ordianryGradePointKVTemp.Add(new StringKeyValue { Key = "C1", Value = 30 });
              ordianryGradePointKVTemp.Add(new StringKeyValue { Key = "C2", Value = 25 });
              ordianryGradePointKVTemp.Add(new StringKeyValue { Key = "C3", Value = 20 });
              ordianryGradePointKVTemp.Add(new StringKeyValue { Key = "D1", Value = 15 });
              ordianryGradePointKVTemp.Add(new StringKeyValue { Key = "D2", Value = 10 });
              ordianryGradePointKVTemp.Add(new StringKeyValue { Key = "D3", Value = 5 });
              ordianryGradePointKVTemp.Add(new StringKeyValue { Key = "E,F,NG", Value = 0 });
              ordianryGradePointKVTemp.Add(new StringKeyValue { Key = "Pass", Value = 30 });
              ordianryGradePointKVTemp.Add(new StringKeyValue { Key = "Merit", Value = 50 });
              ordianryGradePointKVTemp.Add(new StringKeyValue { Key = "Distinction", Value = 70 });
  
  
              OrdinaryGradePointKV = ordianryGradePointKVTemp;
  
          }
  
  
          public void GetHigherGradePairs()
          {
  
              List&lt;StringKeyValue&gt; higherGradePointKVTemp = new List&lt;StringKeyValue&gt;();
  
  
              higherGradePointKVTemp.Add(new StringKeyValue { Key = "A1", Value = 100 });
              higherGradePointKVTemp.Add(new StringKeyValue { Key = "A2", Value = 90 });
              higherGradePointKVTemp.Add(new StringKeyValue { Key = "B1", Value = 85 });
              higherGradePointKVTemp.Add(new StringKeyValue { Key = "B2", Value = 80 });
              higherGradePointKVTemp.Add(new StringKeyValue { Key = "B3", Value = 75 });
              higherGradePointKVTemp.Add(new StringKeyValue { Key = "C1", Value = 70 });
              higherGradePointKVTemp.Add(new StringKeyValue { Key = "C2", Value = 65 });
              higherGradePointKVTemp.Add(new StringKeyValue { Key = "C3", Value = 60 });
              higherGradePointKVTemp.Add(new StringKeyValue { Key = "D1", Value = 55 });
              higherGradePointKVTemp.Add(new StringKeyValue { Key = "D2", Value = 50 });
              higherGradePointKVTemp.Add(new StringKeyValue { Key = "D3", Value = 45 });
              higherGradePointKVTemp.Add(new StringKeyValue { Key = "E,F,NG", Value = 0 });
              higherGradePointKVTemp.Add(new StringKeyValue { Key = "Pass", Value = 30 });
              higherGradePointKVTemp.Add(new StringKeyValue { Key = "Merit", Value = 50 });
              higherGradePointKVTemp.Add(new StringKeyValue { Key = "Distinction", Value = 70 });
  
  
              HigherGradePointKV = higherGradePointKVTemp;
          }
  
  
  
          public void GetSubjectTypes()
          {
              List&lt;Score&gt; subjectList = new List&lt;Score&gt;();
  
              // Adding Subjects to List
              subjectList.Add(new Score { Subject = "Biology" });
              subjectList.Add(new Score { Subject = "Business" });
              subjectList.Add(new Score { Subject = "Business Group" });
              subjectList.Add(new Score { Subject = "Chemistry" });
              subjectList.Add(new Score { Subject = "Classical Studies" });
  
              Subjects = subjectList;
  
          }
  
      }
  }
  </code></pre>