Wpf: Native Support of MVVM Pattern

Created on 11 Mar 2019  路  7Comments  路  Source: dotnet/wpf


I really wish to see that one day, we have a native support for MVVM Pattern in all XAML based applications (Xamarin , UWP , and WPF) like you did in ASP.NET MVC

We need a native support of MVVM Pattern to make it more clean and well structured and no need for injecting tons of services and code editting to set up the project to be ready to be used.

issue-type-design-discussion issue-type-enhancement

Most helpful comment

@AhmedAbuelnour Is there any reason you can't just use Prism, MVVMLight, MvvmCross etc? Why would it need to be dictated by the platform?
IMHO 'patterns' can't really be built-in, as they are just that: "a pattern" that you choose to follow - It's not an API. The APIs for doing MVVM is already there - in fact they are all the way down in .NET Standard which is awesome.
So I'm curious what sort of APIs specifically that you feel a lacking?

All 7 comments

There's all the key MVVM ingredients needed: INotifyPropertyChanged, INotifyCollectionChanged, ICommand, and binding support all out of the box.

Could you explain what you mean by "native support" ?

@dotMorten i meant built-in MVVM Pattern, i know there are some useful classes to make your application MVVM based, but what i mean a ready made MVVM structure of the project, and simplify the process of binding like a command for instance. and the validation process and the navigation between the windows or pages

no need for injecting libraries that change their code every release, that have tons of bugs and messy code structure

ASP.NET MVC for example, is a perfect example for what i mean.

@AhmedAbuelnour Is there any reason you can't just use Prism, MVVMLight, MvvmCross etc? Why would it need to be dictated by the platform?
IMHO 'patterns' can't really be built-in, as they are just that: "a pattern" that you choose to follow - It's not an API. The APIs for doing MVVM is already there - in fact they are all the way down in .NET Standard which is awesome.
So I'm curious what sort of APIs specifically that you feel a lacking?

There are some lakes API with the following
What about direct binding with events and commands ?
what about simple navigation and carrying data with routing?

Frame and NavigationService is already there in WPF, including forwarding data.

Command binding is also already there with ICommand and many controls having Command properties to bind to.

So am I right in saying you just want to be able to bind an event directly to a method? (similar to UWP's x:Bind method binding?)

this should be more like replacing wpf's Binding with UWP's x:Bind and unify the binding experience for both platforms

@dotMorten
The use platforms Extension means basicly that the platform doesn't support the required funtionality, and you have first extend the platform.
Also all These third Party Tools have their limitations, and as they are third Party in some cases their usages are not allowed. Now if you have the experience you can rebuild them all for your own use but the fact that you have to means that it is missing.

Not just this but basicly the current binding implementation doesn't support input Validation hook, so basicly in the bindings you have to add explicitly rules for data Validation. Of Course there is a Workaround for this, but we are again at the Point where the platform doesn't support it out of the box.

And then we come to the really tricky part the command revalidation. There is currently no Default implementations to detect Content changes on Elements which are not present on the ViewModel Level, so if you want to use the commandparameter property of Control you have to still Mirror the value down to ViewModel Level, or you have hook in the CommandManager.RequerySuggested which is also not the best.

Was this page helpful?
0 / 5 - 0 ratings