ViewModel <-> View mapping feature
See original GitHub issueI would like to be able to tell Stylet which View should be created for which ViewModel.
I have a specific use-case where I would like to create multiple VMs but have them all use a single View.
I understand this could be done by subclassing the ViewManager. However, having a simple dictionary that can tell Stylet to create MyView
for both MyViewModel
and MyOtherViewModel
would be a nice feature.
EDIT: Someone pointed this from samples, which seems to be what I need, but I don’t know how I would use that?
EDIT 2: I see the Attribute in there but there’s a couple of issues with it
- You have to apply it to a View (rather than a ViewModel)
AllowMultiple = false
suggests that only 1 ViewModel can be mapped to a single View
Wouldn’t it be better if this attribute was applied to VMs, specifying the View that goes with them?
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Best way to project ViewModel back into Model
I believe best way to map from ViewModel to Entity is not to use AutoMapper for this. AutoMapper is a great tool to...
Read more >Model-View-ViewModel (MVVM)
The view model implements properties and commands to which the view can data bind to, and notifies the view of any state changes...
Read more >FeatureViewModel | API Reference | ArcGIS Maps SDK for ...
A read-only property containing metadata regarding the last edit performed on a feature. more details, FeatureViewModel. map, Map. A reference to the view's...
Read more >Why is it bad to map between a Model and a ViewModel ...
In a recent Pull Request (PR) of mine, a colleague suggested that it was a bad idea to map between a model and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes, you could do exactly that, although it’s mapping from ViewModel -> View of course, not ViewModel -> ViewModel (I’d use
TryGetValue
instead of doing two lookups, but the result is the same). You’ll need the fully-qualified names (including namespace).NamespaceTransformations
are only for transforming namespaces – they map e.g.SomeLibrary.SomeViewModel
toSomeApplication.SomeView
. You can see that they match the start of the ViewModel’s type name, and end at a.
. This can be needed for the convention-based mapping that Stylet does out of the box.@canton7 excuse my ignorance are you saying I could technically do something like this:
Where map would be say
Is that not what this technically does if I understood it right? https://github.com/canton7/Stylet/blob/master/Stylet/ViewManager.cs#L107