Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: can you inject NavigationService into the BaseViewModel #443

Closed
dhaligas opened this issue Feb 3, 2016 · 9 comments
Closed

Question: can you inject NavigationService into the BaseViewModel #443

dhaligas opened this issue Feb 3, 2016 · 9 comments

Comments

@dhaligas
Copy link

dhaligas commented Feb 3, 2016

Is there a way to always have the BaseViewModel inject the NavigationService?

I would like to wrap the functions esp to have a single place to handle double tapping / modals etc

@brianlagunas
Copy link
Member

What BaseViewModel? Prism doesn't have a BaseViewModel. What platform are you using?

@dhaligas
Copy link
Author

dhaligas commented Feb 3, 2016

I am using

BaseViewModel : BindableBase, INavigationAware

I want to know if I can inject services into my BaseViewModel that every ViewModel inherits

I guess I could write an extension to the navigation service to handle the double tap

@brianlagunas
Copy link
Member

You can, but you have to also inject them into your derived class and pass them to your base ctor.

Why would you modify the NavigationSevice to handle a double tap? That should be handled by your UI, and you would call a navigation action on the double tap.

What platform?

@dhaligas
Copy link
Author

dhaligas commented Feb 3, 2016

I am handling the case where the command is invoked faster than it can complete the first tap.

I have had issues in apps with the tap gesture and the ability to tap it fast and get multiple pages pushed to the stack

@brianlagunas
Copy link
Member

What platform?

@dhaligas
Copy link
Author

dhaligas commented Feb 3, 2016

mostly on android but sometimes on iOS

@brianlagunas
Copy link
Member

Okay, so you are using Xamarin.Forms. Once again, this is not something you will handle in the navigation service. The TabGestureRecognizer has a property that lets you define a double tab called NumberOfTapsRequired. If you want to prevent a double tap, then you need to handle this logic in your ViewModel, not the navigation service.

@dhaligas
Copy link
Author

dhaligas commented Feb 3, 2016

ok makes sense like this question
#442

@lock
Copy link

lock bot commented Jan 31, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 31, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants