title: How to get and bind the value of Slider in C# WPF?
body: <p>I can get the value of slider here:</p>
  
  <pre><code>    public void TheSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs&lt;double&gt; e)
      {
  
  
          int k = (int)TheSlider.Value;
  
          Debug.WriteLine(k);
  
      }
  </code></pre>
  
  <p>In this part, I cant get the value, so I cant use it :</p>
  
  <pre><code>    private void Window_Loaded(object sender, RoutedEventArgs e)
      {
         _runtime.NuiCamera.ElevationAngle = (int)TheSlider.Value;
      }
  </code></pre>
  
  <p>This is the slider code in xaml:</p>
  
  <pre><code>    &lt;Slider x:Name="TheSlider"
              DockPanel.Dock="Left"
              Orientation="Horizontal"
              HorizontalAlignment="Center"
              HorizontalContentAlignment="Center"
              Minimum="-27"
              Maximum="27"
              Cursor="Hand"
              IsSnapToTickEnabled="True"
              Margin="322,392,329,87" ValueChanged="TheSlider_ValueChanged" Width="144" /&gt;
  </code></pre>
  
  <p>What is the problem here? Can you help me please?</p>
  
  <p>UPDATE:</p>
  
  <pre><code>        public override void OnApplyTemplate()
      {
          base.OnApplyTemplate();
          System.Windows.Data.Binding b = new System.Windows.Data.Binding();
          b.ElementName = "TheSlider";
          b.Path = new PropertyPath("Value");
          SetBinding(ElevationAngleProperty, b);
  
      }
  
      public int ElevationAngle
      {
          get { return _runtime.NuiCamera.ElevationAngle; }
  
          set { _runtime.NuiCamera.ElevationAngle = value; OnPropertyChanged("ElevationAngle"); }
      }
  
  
      public DependencyProperty ElevationAngleProperty { get; set; }
  </code></pre>