Closed boop5 closed 3 years ago
I don't follow I'm afraid. What would ActivateItem do with the params? It also looks like you're trying to activate the event, rather than the ViewModel?
When I do things like this, I have a navigation service, which defines a bunch of different methods which each take a set of strongly-typed parameters as necessary. So you'd call NavigateToLogin(param1, param2)
rather than NavigateTo(typeof(Login ViewModel), new Dictionary<string, object>() { { "param1", param1}, { "param2", param2 } })
. The navigation service would then instantiate the VM and pass in the parameters as constructor parameters. This had the advantage of not relying on weakly-typed dictionaries which only catch errors at runtime, and also means the caller doesn't need to know the type of the final ViewModel.
Thanks for your input. You helped me a lot.
It looks like that
IConductor<T>
does not provide a way to activate items with some kind of parameters.I want to have some kind of NavigationService which works like this
and my conductor would do something like this
Obviously I could create ViewModels manually and pass my parameters like that. But I'd like to do it as I explained above. Is there a way I can do that with Stylet?