title: How can I know who raised a routed event in WPF?
body: <p>I have a slider, and I'm updating the value internally. But also, user input is accepted, to change an internal parameter.</p>
  
  <p>The question is: how can I know who raised the event, the user or the class where I change slider.value?</p>
  
  <p>In my case, this is the handler:</p>
  
  <pre><code>    private void Slider_ValueChanged(object sender, RoutedPropertyChangedEventArgs&lt;double&gt; e)
  {
          var slider = sender as Slider;
          if (slider == null) return;
  
          var col = this.SelectedColor;
          switch ((string)slider.Tag)
          {
              case "Hue": this.SetHue(ValueHue.Value); break; 
              case "Sat": this.SetSatBri(ValueSat.Value, CurrentBri); break;  
              case "Bri": this.SetSatBri(CurrentSat, ValueBri.Value); break;  
              case "R": this.SetColor(Color.FromRgb(Convert.ToByte(ValueR.Value), col.G, col.B)); break;
              case "G": this.SetColor(Color.FromRgb(col.R, Convert.ToByte(ValueG.Value), col.B)); break;
              case "B": this.SetColor(Color.FromRgb(col.R, col.G, Convert.ToByte(ValueB.Value))); break;
          }
  }
  </code></pre>
  
  <p>The function doesn't work correctly if the event wasn't raised by user input. So how can I find that out?</p>