Discussion: MVVM-friendly ContentDialog #7465
Replies: 4 comments
-
@MikeHillberg FYI |
Beta Was this translation helpful? Give feedback.
-
I think this makes sense too. Across Windows we generally avoid a property for showing UI, preferring a Show method instead (there's a lot of those). But we treat Xaml special specifically to enable data binding and MVVM, thus flyouts have both the IsOpen property and the ShowAt method. I'd just change the example here to listen to the ContentDialog's built-in OK button (PrimaryButtonClick) rather than having one in its content area. |
Beta Was this translation helpful? Give feedback.
-
I agree, if it is possible to add a property and don't change other APIs, it would be good backward compatible solution. |
Beta Was this translation helpful? Give feedback.
-
Just noticed one related thing about IsOpen: this property cannot be set for FlyoutBase. |
Beta Was this translation helpful? Give feedback.
-
Discussion: Current API of ContentDialog is not MVVM-friendly
It forces developers to call ShowAsync to open dialog. But ContentDialog is obviously part of View layer and this makes it incompatible or inconvenient for use with MVVM, because:
So, usually developers have to create some DialogService and pretend that it's fine, because services live apart from Models, Views and ViewModels.
I believe there should have been just a bindable property "IsOpen" here instead of the method. In addition, it is strange that ContentDialog provides limited set of predefined buttons because it is Content dialog after all and developer can add whatever he needs as content.
So, what I would be happy to see instead of current ContentDialog would look like following:
Related Links
Current ContentDialog API
Beta Was this translation helpful? Give feedback.
All reactions