canton7 / Stylet

A very lightweight but powerful ViewModel-First MVVM framework for WPF for .NET Framework and .NET Core, inspired by Caliburn.Micro.
MIT License
988 stars 143 forks source link

How can i raise TextBox KeyDown event? #143

Closed CodingOctocat closed 4 years ago

CodingOctocat commented 4 years ago

I try:

<TextBox KeyDown="{s:Action MyKeyDown}" />
private void MyKeyDown(object sender, KeyEventArgs e)
{
    // stuff...
}

doesn't work.

canton7 commented 4 years ago

What does "doesn't work" mean? What exactly happens, which makes you think that it doesn't work?

kaisame commented 4 years ago

The bind method is not running,MyKeyDown method do not response.

canton7 commented 4 years ago

It works for me. Here's a project which demonstrates it working:

TestProject.zip

Please provide a minimal reproducible example which demonstrates your issue.

kaisame commented 4 years ago

TestProject.zip MykeyDown method only response 'enter','alt','crtl' ,'window' event.

canton7 commented 4 years ago

I don't know what you're trying to say I'm afraid.

Maybe you want the PreviewKeyDown event?

kaisame commented 4 years ago

thanks.That is what I need