문제

I have a Command bound to my MainWindow via CommandBinding to the Delete key.

I want that, depending on the context (which element is active), the same command would be translated to different delete commands that semantically delete things.

In few words, I want that pressing the Delete key will delete things depending on where the focus is at that moment.

I have heard about CompositeCommands (PRISM), but I don't know whether that is useful an easily applicable here.

Thanks a lot!

도움이 되었습니까?

해결책

CompositeCommand in Prism helps you register several commands in one, so that all can be called at the same time.

Since you use MVVM, you should have a ViewModel for each kind of object at least. If you have something like a ViewModelBase or an IViewModel, you could simply add a command to it, and initialize it differently in each ViewModel.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top