WPF: How to attach mouse events to a viewmodel?

后端 未结 6 1995
南笙
南笙 2021-02-04 19:47

I am trying to use the MVVM pattern for the first time. So I have an ItemsControl filled with my viewmodel objects, displayed using DataTemplate\'s; th

6条回答
  •  离开以前
    2021-02-04 20:28

    There are ways to do that without code-behind...

    You could use the attached behavior pattern to map events to commands, see Marlon Grech's implementation here

    You could also use a markup extension that I wrote to bind InputBindings to ViewModel commands, like this :

    
        
    
    

    However I'm not sure it fits your specific needs...

提交回复
热议问题