Search code examples
c#wpfevent-handlinglabelcode-behind

How do I execute an event when a label is clicked?


I want to add a click event handler when a WPF label is clicked. The idea is to do it code behind, because I´m generating the interface dynamically base on a document.


Solution

  • If I understand this correctly, you want a Label with a LeftMouseDown-event, which you would write from code?

    In that case:

    TestLabel.MouseLeftButtonDown += new MouseButtonEventHandler(TARGET);