title: Using SetValue to add an event handler
body: <p>This code works</p>
  
  <pre><code>TextBlock tbTest = new TextBlock();
  tbTest.MouseRightButtonDown += new MouseButtonEventHandler(cc_CopyToClip);
  </code></pre>
  
  <p>But I need to do the same thing with a SetValue<br>
  This does not work - compiler error   </p>
  
  <pre><code>FrameworkElementFactory textblock = new FrameworkElementFactory(typeof(TextBlock));
  textblock.SetValue(TextBlock.MouseRightButtonDownEvent, += new MouseButtonEventHandler(cc_CopyToClip));
  </code></pre>
  
  <p>How to assign an event handler via SetValue?</p>
  
  <p>Answer</p>
  
  <pre><code>textblock.AddHandler(TextBlock.MouseRightButtonDownEvent, new MouseButtonEventHandler(cc_CopyToClip));
  </code></pre>