title: Binding not updated with DataTemplateSelector
body: <p>I have a WPF application based on MVVM. 
  It has paramaters that can be set. A paramater can be a list of strings in a checkbox or a double in a numupdown. Every device has its own parameters, so the parameters are dynamically loaded. Thats why i use a DataTemplateSelector.</p>
  
  <p>Xaml code</p>
  
  
  
  <pre><code>&lt;ItemsControl ItemsSource="{Binding ParameterWrapperList}" ItemTemplateSelector="{StaticResource propertyDataTemplateSelector}"&gt;
      &lt;ItemsControl.ItemsPanel&gt;
        &lt;ItemsPanelTemplate&gt;
          &lt;StackPanel Orientation="Horizontal"&gt;&lt;/StackPanel&gt;
        &lt;/ItemsPanelTemplate&gt;
      &lt;/ItemsControl.ItemsPanel&gt;
  &lt;/ItemsControl&gt;
  </code></pre>
  
  <p>The templates are in a resource dictionary:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>    &lt;DataTemplate x:Key="doubleTemplate"&gt;
          &lt;Grid Visibility="{Binding Parameter.ParameterModel.IsVisible, Converter={StaticResource Visibility}}"&gt;
              &lt;Grid.RowDefinitions&gt;
                  &lt;RowDefinition Height="{Binding Path=RowHeight, Mode=OneWay}"/&gt;
                  &lt;RowDefinition/&gt;
              &lt;/Grid.RowDefinitions&gt;
              &lt;Border Grid.Row="0" Style="{StaticResource HeaderBorderStyle}" Width="{Binding Width}" Visibility="{Binding HeaderVisibility, Converter={StaticResource Visibility}}"&gt;
                  &lt;StackPanel Orientation="Horizontal"&gt;
                      &lt;Label Content="{Binding Parameter.DisplayName}"/&gt;
                  &lt;/StackPanel&gt;
              &lt;/Border&gt;
              &lt;Border Grid.Row="1" Style="{StaticResource ItemBorderStyle}" Width="{Binding Width}"&gt;                
                  &lt;telerik:RadNumericUpDown Name="nudParameterValue" Value="{Binding Path=ParameterValue, Mode=TwoWay}" Minimum="{Binding Parameter.ParameterModel.MinimumValue}" Maximum="{Binding Parameter.ParameterModel.MaximumValue}" NumberDecimalDigits="{Binding Parameter.ParameterModel.NumberDecimalDigits}" SmallChange="{Binding Parameter.ParameterModel.SmallChanges}"/&gt;                                   
              &lt;/Border&gt;
          &lt;/Grid&gt;
      &lt;/DataTemplate&gt;
      &lt;DataTemplate x:Key="stringTemplate"&gt;
          &lt;Grid Visibility="{Binding Parameter.ParameterModel.IsVisible, Converter={StaticResource Visibility}}"&gt;
              &lt;Grid.RowDefinitions&gt;
                  &lt;RowDefinition Height="{Binding Path=RowHeight, Mode=OneWay}"/&gt;
                  &lt;RowDefinition/&gt;
              &lt;/Grid.RowDefinitions&gt;
              &lt;Border Grid.Row="0" Style="{StaticResource HeaderBorderStyle}" Width="{Binding Width}" Visibility="{Binding Path=HeaderVisibility, Converter={StaticResource Visibility}}"&gt;
                  &lt;Label Content="{Binding Parameter.DisplayName}"/&gt;
              &lt;/Border&gt;
              &lt;Border Grid.Row="1" Style="{StaticResource ItemBorderStyle}" Width="{Binding Width}" &gt;
                  &lt;ComboBox ItemsSource="{Binding Path=Parameter.ParameterModel.PossibleValues}" SelectedIndex="{Binding ParameterValue, Mode=TwoWay}"&gt;
  
                  &lt;/ComboBox&gt;
              &lt;/Border&gt;
          &lt;/Grid&gt;
      &lt;/DataTemplate&gt;
      &lt;configControl:PropertyDataTemplateSelector
              StringTemplate="{StaticResource stringTemplate}"
              DoubleTemplate="{StaticResource doubleTemplate}"
              x:Key="propertyDataTemplateSelector"/&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>I wrote the code for the DataTemplateSelector. </p>
  
  <pre><code>    public class PropertyDataTemplateSelector : DataTemplateSelector
  {
      public DataTemplate DoubleTemplate { get; set; }
      public DataTemplate StringTemplate { get; set; }
  
      public override DataTemplate SelectTemplate(object item,
                 DependencyObject container)
      {
          DeviceModel.ParameterType devFunct = ((ParameterWrapper)item).Parameter.ParameterModel.Type;
          switch (devFunct)
          {
              case DeviceModel.ParameterType.Double:
                  return DoubleTemplate;
              case DeviceModel.ParameterType.String:
                  return StringTemplate;
              default:
                  return null;
          }
          return null;            
      }
  }
  </code></pre>
  
  <p>When the applications opens all the values are set fine. But when i update ParameterValue, it isn't updated on view. (when i output the values in console window, the values are set fine (but not in the GUI)).</p>
  
  <p>What should i do to make this work.</p>
  
  <p><strong>Edit</strong></p>
  
  <p>This is the code it's bound to. Every function has a checkbox and when you change the parameter of one, all other parameters that are checked need to change.</p>
  
  <pre><code>        public double ParameterValue
      {
          get
          {
              return _parameter.ParameterValue;
          }
          set
          {
              Parameter.ParameterValue = value;
              Console.WriteLine("ParameterValueChanged");
              if (SetOthers)
              {
                  if (_parentFunction.Checked)
                  {
                      foreach (var function in _parentFunction.FunctionWrapperList)
                      {
                          if (function.Checked)
                          {
                              foreach (var parameterWrapper in function.ParameterWrapperList)
                              {
                                  if (parameterWrapper.Parameter != this.Parameter)
                                  {
                                      if (parameterWrapper.Parameter.ParameterModel == Parameter.ParameterModel)
                                      {
                                          Console.WriteLine(function.Function.Name + " " + function.Checked + " " + Parameter.ParameterValue);
                                          parameterWrapper.SetValue(Parameter.ParameterValue);
                                      }
                                  }
                              }
                          }
                      }
                  }
              }
              Notify("ParameterValue");
          }
      }
  
      private void SetValue(double parameterValue)
      {
          SetOthers = false;
          Parameter.ParameterValue = parameterValue;
          SetOthers = true;
      }
  </code></pre>
  
  <p>The boolean SetOthers is so he won't get a stackoverflow and keeps setting itself.</p>