Hi,
I'm using dependency injection in my app but the way that Template10 use to resolve ViewModels is not suitable, Why do I say that? Cause :
I needed to set a ViewModel for the Shell (the one with HamburgurMenu Template) and I created one (just for the case if you ask why : cause I needed to Show The User Profile in the HamburgurMenu as all the other apps do) but I found out that the ResolveForPage is not getting called any more!
so I read Template10 Source Code and I found out that after navigation it checks for whether the DataContext is null or cannot be Casted to INavigable then if it passes it calls the ResolveForPage Method and sets the datacontext.
And here is the problem! the datacontext of the shell is coming down to every page so their DataContext is Never null!
isn't it a better approach to set the ViewModel similar to the way that Prism does? after all they are the Experts of MVVM!
Workaround : We can set DataContext to null in the Page Constructor.
10.2 of Template10 is being refactored to better support DI.
@darenm Thank you , and do you know when it will be ready? is it coming after RS3 ? if so , do you have any idea when that one will be released?
Take a look at #1519 for more insight - tl;dr 10.2 is shooting for RS3.
I think 10.1 made things too hard for MVVM developers using DI in that it called ResolveForPage() after navigation instead of before. With 10.2, ResolveForPage() will be called before navigation, which enables INavigatingTo, a special interface that is more relevant to Android/Xamarin apps, but drives home when in the pipeline it is called. 10.2 will support INavigatingTo, INavigatedTo, INavigatingFrom, INavigatedFrom, and ICanNavigate to complete the cycle for every use case, and heavily inspired by Prism, to be honest. It doesn't mean you must use DI, but it means that if you are, it will make life easier because it will occur when you expect it to. I think we can enable your scenario in 10.1 if you are blocked, otherwise, I would love for you to help me test 10.2 in the next week or two when we have our very early preview.
@JerryNixon Thank you for your response, no it's not blocking I just needed to set datacontext to null in every page and now it's working properly.
I'll happily test T10.2 as soon as I can get it. cause I can't wait to see the NavigationView 馃榿
one more thing : Is there going to be something like InteractionRequest Type in the next version? (This is the type which enables us to open a Custom Dialog -for example Content Dialog in UWP- from the ViewModel) again this is from Prism. I know I'm asking everything from Prism 馃榿but I can't stop using some of the features that T10 gives us Like controls and services ...
And I'm sorry for not coding these myself cause I'm still learning and I may be more a problem than a help.
Yes, we are building out the Dialog service now. We will auto-register it so view-models can request it through DI, and we will implement both Content and Message so you can pick and there will be a central manager to make sure only one is visible at a time. There will be a few extension methods who don't use DI or view-models, too.