views:

37

answers:

2

Can i set a mouselistener (Clicked) in WPF?

+1  A: 

If te user clicked where? If you have a button(or window or pretty much anything else) you simpy add the MouseDown() eventhandler....

sklitzz
+2  A: 

Simple,

  • Just a Click attribute to your xaml control
  • Assign it a handler
  • Define the handler in your xaml.cs

In your xaml,

<Button Click="Button_Click"></Button>

In your xaml.cs,

    private void Button_Click(object sender, RoutedEventArgs e)
    {
        //What should be done when you click the control
    }

There are loads of mouse events available. Check MSDN for the list of mouse events supported in WPF

sudarsanyes