简体   繁体   中英

Catel application-wide commands only in focused control

Is it possible to register an application command in Catel which would fire only when specific control has a focus?

For example, in the Catel.Examples.WPF.Commanding example, ( https://github.com/Catel/Catel.Examples/tree/master/src/NET/Catel.Examples.WPF.Commanding ) if I replace TextBlock with TextBox and add RibbonButton s with ApplicationCOmmands.Cut and ApplicationCommands.Paste , these Application commands work only on focused TextBox .

Is it possible to make Refresh command execute only on the DocumentView which has a focus?

Alternatively, is there an example or guidance on using RoutedUICommands with Catel and its ICommandManager ?

Thanks, Tom

This is possible if you register an empty app-wide command. Then you can add an action / subcommand whenever you initialize a view model and unregister when the vm is closed again. This way, the command will be invoked against all "open" instances (and only be executable if one or more subcommands are available).

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