Shell icon indicating copy to clipboard operation
Shell copied to clipboard

navigate Pass data to ViewModel

Open zyknow opened this issue 2 years ago • 4 comments

like maui shell,when ViewModel has IQueryAttributable,that can doing this image

but in Page ArgumentAsync method also can doing likeness function

so, i don't sure in this rep to Implement IQueryAttributable function is necessary

zyknow avatar Sep 19 '23 02:09 zyknow

and i think Maui QueryProperty is very useful ,but not only can use in Page, also can use in ViewModel image

zyknow avatar Sep 19 '23 02:09 zyknow

Hello @zyknow Thanks for sharing the idea. I will take how it works and whether we can do it here or not.

OmidID avatar Sep 19 '23 08:09 OmidID

I saw that there is a navigate overload in Navigator Task NavigateAsync(string path, object? argument, CancellationToken cancellationToken = default);

however, the argument is never passed to the target view. Instead, the OnNavigatingAsync and OnNavigateAsync are only called on the page that is navigated away from.

Am I missing something, or is this a bug/intended?

I'd be willing to work on this feature, if you approve

gentledepp avatar Apr 29 '24 08:04 gentledepp

Hello @gentledepp You should use the method ArgumentAsync If you use Page class then override the method otherwise if you use your own base class then implement the INavigationLifecycle and you will have the ArgumentAsync

OnNavigatingAsync allow you to override the parameters of navigating or cancel the navigation. and OnNavigateAsync when navigation is over.

OmidID avatar May 06 '24 11:05 OmidID

As we do not have activity here for long time, I closing this issue For MVVM pattern and pass data to ViewModel, you can take a looks to our wiki

https://github.com/AvaloniaInside/Shell/wiki/ViewModel-and-State-Example

OmidID avatar Aug 28 '24 11:08 OmidID