简体   繁体   中英

Is something like keylistener in c# WPF

What i need is after move with mouse on button call function. In java, there is mouselistener and method what do it. How i can make it in C# WPF? Is there something similar?

I tried google but find nothing.

Add element on XAML

<Button ....... MouseMove="Button1MouseMove">

in your file.cs

private void Button1MouseMouve(object sender,MouseEventArgs e)
{
    Point position = e.GetPosition(this);
    int mouse_x = position.x;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM