title: Update WPF Slider dynamically based on textbox
body: <p>I am writing a WPF application and I have a slider bound to a textbox and vice versa. </p>
  
  <p>My problem is that when changing the value of the text box, I have to click out of the text box before the value of the slider is updated. </p>
  
  <p>I would like the slider value to change as the user types text into the textbox or when the user presses enter whilst in the text box. </p>
  
  <p>Heres the code I have:</p>
  
  <p>XAML:</p>
  
  <pre><code>&lt;Slider Name="sldrConstructionCoreSupplierResin" Minimum="0" Maximum="10" Grid.Column="1" Grid.Row="1" IsSnapToTickEnabled="True"/&gt;
      &lt;TextBox Name="txtConstructionCoreSupplierResin" Text="{Binding ElementName=sldrConstructionCoreSupplierResin, Path=Value, Converter={StaticResource RoundingConverter}}" Grid.Column="2" Grid.Row="1"/&gt;
  </code></pre>
  
  <p>Code Behind:</p>
  
  <pre><code>public class RoundingConverter : IValueConverter
      {
          public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
          {
              if (value != null)
              {
                  double dblValue = (double)value;
                  return (int)dblValue;
              }
              return 0;
          }
  
          public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
          {
              if (value != null)
              {
                  int ret = int.Parse(value.ToString());
                  return ret;
              }
              return 0;
          }
      } 
  </code></pre>