MVVM – Simple Generic<T> Event Commands With Attached Properties

added by ButtonChrome
11/10/2010 1:16:34 AM

1 Kicks, 200 Views

One of the challenges of MVVM is to favour command bindings over handling routed events, as currently all event handling must happen in the ‘code behind’ file rather than the ViewModel – which breaks the pattern. There are many elaborate and highly engineered strategies that I have seen to solve this, but maybe we could use a simple attached property implementation to achieve the desired effect. Also, WPF bindings (including command bindings) don't support generics, but maybe we could use type inference to create a generic implementation.