Has x:bind in WinUI 3 effectively killed commanding and converters?
-
I know commanding and converters have been a staple of MVVM pattern and XAML interfaces, but it seems like WinUI 3 is moving away from those, particularly in terms of the functionality offered (direct binding to functions and events) and seemingly encouragement in the documentation to use them instead of commands and converters. I'm in the middle of refactoring a WPF application to WinUI 3, and after writing several XAML pages, it looks like it's going to be possible to avoid commands and converters altogether. So is it an MVVM sin to wholly replace commands and converters with x:Bind functions?
Randy
-
I know commanding and converters have been a staple of MVVM pattern and XAML interfaces, but it seems like WinUI 3 is moving away from those, particularly in terms of the functionality offered (direct binding to functions and events) and seemingly encouragement in the documentation to use them instead of commands and converters. I'm in the middle of refactoring a WPF application to WinUI 3, and after writing several XAML pages, it looks like it's going to be possible to avoid commands and converters altogether. So is it an MVVM sin to wholly replace commands and converters with x:Bind functions?
Randy
MS samples are meant to show language features. They don't "do MVVM" unless the article is about MVVM. x:Bind provides some additional type checking at design time and some performance advantages versus "Binding"; with trade-offs. Nothing to do with MVVM in particular.
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
-
MS samples are meant to show language features. They don't "do MVVM" unless the article is about MVVM. x:Bind provides some additional type checking at design time and some performance advantages versus "Binding"; with trade-offs. Nothing to do with MVVM in particular.
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
Thanks, Gerry. My WPF application code was fairly consistent in its application of Binding with commands and converters, and I'd like to continue that level of consistency as I refactor it to WinUI 3. I'd like to take advantage of the x:Bind performance improvements, but also remain consistent in the way it's used. In other words, I'd prefer to continue to wholly use Binding (to DataContext) with traditional commands and converters, wholly use x:Bind (to code-behind objects) with traditional commands and converter classes, or wholly use x:Bind with functions (no commands or converters). This may not make sense or be possible, I just haven't gotten far enough into it to tell. So far I haven't found any showstoppers, and that's why I'm curious. But I'm also only about 10% into it.