Need to overide the navigation methodMultiple navigation control through dependency injectionCreate Generic method constraining T to an EnumHow do I use reflection to call a generic method?Why is it important to override GetHashCode when Equals method is overridden?How to mark a method as obsolete or deprecated?MEF part unable to import Autofac autogenerated factoryIs it possible to catch an exception you can't handle (in C#)?How to call asynchronous method from synchronous method in C#?Populate initial view model data using caliburn micro and autofacAutofac multithreading issuesPassing a selected item of listbox into a xaml
Taking advantage when HR forgets to communicate the rules
Intern not wearing safety equipment; how could I have handled this differently?
Need a non-volatile memory IC with near unlimited read/write operations capability
Chilling juice in copper vessel
How should I ask for a "pint" in countries that use metric?
Floating Pumice Road. Slab Size
Why is there paternal, for fatherly, fraternal, for brotherly, but no similar word for sons?
How do resistors generate different heat if we make the current fixed and changed the voltage and resistance? Notice the flow of charge is constant
Did William Shakespeare hide things in his writings?
NOLOCK or Read Uncommitted locking / latching behaviours
Why do airports remove/realign runways?
Users forgotting to regenerate PDF before sending it
What are some bad ways to subvert tropes?
Taking my Ph.D. advisor out for dinner after graduation
What exactly is a "murder hobo"?
Possibility to correct pitch from digital versions of records with the hole not centered
How to evaluate the performance of open source solver?
How to have a filled pattern
How did the Time Lords put a whole "Star" in a Tardis?
Why did the frequency of the word "черт" (devil) in books increase by a few times since the October Revolution?
What factors could lead to bishops establishing monastic armies?
Why is whale hunting treated differently from hunting other animals?
Computer name naming convention for security
I don't want to be introduced as a "Minority Novelist"
Need to overide the navigation method
Multiple navigation control through dependency injectionCreate Generic method constraining T to an EnumHow do I use reflection to call a generic method?Why is it important to override GetHashCode when Equals method is overridden?How to mark a method as obsolete or deprecated?MEF part unable to import Autofac autogenerated factoryIs it possible to catch an exception you can't handle (in C#)?How to call asynchronous method from synchronous method in C#?Populate initial view model data using caliburn micro and autofacAutofac multithreading issuesPassing a selected item of listbox into a xaml
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I am using autofac for dependency injection and I need to override the navigation function. in order to do that I did
Locator.cs(where contain the Cs files)
private readonly ContainerBuilder _builder;
public locator()
_builder = new ContainerBuilder();
register();
Container = _builder.Build();
public IContainer Container get; set;
private void register()
_builder.RegisterType<vm>().As<Ivm>();
_builder.RegisterType<Vm1>();
_builder.RegisterType < basevm>();
_builder.RegisterType<MainPage>();
_builder.RegisterType<xa>();
In my app.Xaml.cs
In constructor
public App()
InitializeComponent();
locator locator1 = new locator();
Container = locator1.Container;
MainPage = new NavigationPage(Container.Resolve<MainPage>());
public static IContainer Container;
then I tried to override the navigation func in my main page code behind it cannot be override. what I am missing and where i use this
public abstract void Navigate(SelectedItemChangedEventArgs e);
public override async void Navigate(SelectedItemChangedEventArgs e)
xa patientListViewPage = App.Container.Resolve<xa>();
await Navigation.PushAsync(patientListViewPage);
why this is not working. I occur this error
'MainPage.Navigate(SelectedItemChangedEventArgs)': no suitable method found to override
c# mvvm xamarin.forms autofac
add a comment |
I am using autofac for dependency injection and I need to override the navigation function. in order to do that I did
Locator.cs(where contain the Cs files)
private readonly ContainerBuilder _builder;
public locator()
_builder = new ContainerBuilder();
register();
Container = _builder.Build();
public IContainer Container get; set;
private void register()
_builder.RegisterType<vm>().As<Ivm>();
_builder.RegisterType<Vm1>();
_builder.RegisterType < basevm>();
_builder.RegisterType<MainPage>();
_builder.RegisterType<xa>();
In my app.Xaml.cs
In constructor
public App()
InitializeComponent();
locator locator1 = new locator();
Container = locator1.Container;
MainPage = new NavigationPage(Container.Resolve<MainPage>());
public static IContainer Container;
then I tried to override the navigation func in my main page code behind it cannot be override. what I am missing and where i use this
public abstract void Navigate(SelectedItemChangedEventArgs e);
public override async void Navigate(SelectedItemChangedEventArgs e)
xa patientListViewPage = App.Container.Resolve<xa>();
await Navigation.PushAsync(patientListViewPage);
why this is not working. I occur this error
'MainPage.Navigate(SelectedItemChangedEventArgs)': no suitable method found to override
c# mvvm xamarin.forms autofac
What are you trying to achieve here? Most apps would introduce a service dedicated to navigation, that would wire in your DI that way rather than hacking the NavigationPage's Navigation itself.
– Rudi Visser
Mar 21 at 22:04
I don't need to any framework. in this case I need to create my own navigation system using di can it possible
– ish1104
Mar 22 at 3:23
I'm not suggesting a framework, I'm suggesting a service dedicated to navigation, rather than calling straight onto the Navigation object itself. Take a look at Enterprise App Navigation from Microsoft that should describe better what I'm suggesting.
– Rudi Visser
Mar 22 at 9:59
add a comment |
I am using autofac for dependency injection and I need to override the navigation function. in order to do that I did
Locator.cs(where contain the Cs files)
private readonly ContainerBuilder _builder;
public locator()
_builder = new ContainerBuilder();
register();
Container = _builder.Build();
public IContainer Container get; set;
private void register()
_builder.RegisterType<vm>().As<Ivm>();
_builder.RegisterType<Vm1>();
_builder.RegisterType < basevm>();
_builder.RegisterType<MainPage>();
_builder.RegisterType<xa>();
In my app.Xaml.cs
In constructor
public App()
InitializeComponent();
locator locator1 = new locator();
Container = locator1.Container;
MainPage = new NavigationPage(Container.Resolve<MainPage>());
public static IContainer Container;
then I tried to override the navigation func in my main page code behind it cannot be override. what I am missing and where i use this
public abstract void Navigate(SelectedItemChangedEventArgs e);
public override async void Navigate(SelectedItemChangedEventArgs e)
xa patientListViewPage = App.Container.Resolve<xa>();
await Navigation.PushAsync(patientListViewPage);
why this is not working. I occur this error
'MainPage.Navigate(SelectedItemChangedEventArgs)': no suitable method found to override
c# mvvm xamarin.forms autofac
I am using autofac for dependency injection and I need to override the navigation function. in order to do that I did
Locator.cs(where contain the Cs files)
private readonly ContainerBuilder _builder;
public locator()
_builder = new ContainerBuilder();
register();
Container = _builder.Build();
public IContainer Container get; set;
private void register()
_builder.RegisterType<vm>().As<Ivm>();
_builder.RegisterType<Vm1>();
_builder.RegisterType < basevm>();
_builder.RegisterType<MainPage>();
_builder.RegisterType<xa>();
In my app.Xaml.cs
In constructor
public App()
InitializeComponent();
locator locator1 = new locator();
Container = locator1.Container;
MainPage = new NavigationPage(Container.Resolve<MainPage>());
public static IContainer Container;
then I tried to override the navigation func in my main page code behind it cannot be override. what I am missing and where i use this
public abstract void Navigate(SelectedItemChangedEventArgs e);
public override async void Navigate(SelectedItemChangedEventArgs e)
xa patientListViewPage = App.Container.Resolve<xa>();
await Navigation.PushAsync(patientListViewPage);
why this is not working. I occur this error
'MainPage.Navigate(SelectedItemChangedEventArgs)': no suitable method found to override
c# mvvm xamarin.forms autofac
c# mvvm xamarin.forms autofac
asked Mar 21 at 12:02
ish1104ish1104
1471 silver badge15 bronze badges
1471 silver badge15 bronze badges
What are you trying to achieve here? Most apps would introduce a service dedicated to navigation, that would wire in your DI that way rather than hacking the NavigationPage's Navigation itself.
– Rudi Visser
Mar 21 at 22:04
I don't need to any framework. in this case I need to create my own navigation system using di can it possible
– ish1104
Mar 22 at 3:23
I'm not suggesting a framework, I'm suggesting a service dedicated to navigation, rather than calling straight onto the Navigation object itself. Take a look at Enterprise App Navigation from Microsoft that should describe better what I'm suggesting.
– Rudi Visser
Mar 22 at 9:59
add a comment |
What are you trying to achieve here? Most apps would introduce a service dedicated to navigation, that would wire in your DI that way rather than hacking the NavigationPage's Navigation itself.
– Rudi Visser
Mar 21 at 22:04
I don't need to any framework. in this case I need to create my own navigation system using di can it possible
– ish1104
Mar 22 at 3:23
I'm not suggesting a framework, I'm suggesting a service dedicated to navigation, rather than calling straight onto the Navigation object itself. Take a look at Enterprise App Navigation from Microsoft that should describe better what I'm suggesting.
– Rudi Visser
Mar 22 at 9:59
What are you trying to achieve here? Most apps would introduce a service dedicated to navigation, that would wire in your DI that way rather than hacking the NavigationPage's Navigation itself.
– Rudi Visser
Mar 21 at 22:04
What are you trying to achieve here? Most apps would introduce a service dedicated to navigation, that would wire in your DI that way rather than hacking the NavigationPage's Navigation itself.
– Rudi Visser
Mar 21 at 22:04
I don't need to any framework. in this case I need to create my own navigation system using di can it possible
– ish1104
Mar 22 at 3:23
I don't need to any framework. in this case I need to create my own navigation system using di can it possible
– ish1104
Mar 22 at 3:23
I'm not suggesting a framework, I'm suggesting a service dedicated to navigation, rather than calling straight onto the Navigation object itself. Take a look at Enterprise App Navigation from Microsoft that should describe better what I'm suggesting.
– Rudi Visser
Mar 22 at 9:59
I'm not suggesting a framework, I'm suggesting a service dedicated to navigation, rather than calling straight onto the Navigation object itself. Take a look at Enterprise App Navigation from Microsoft that should describe better what I'm suggesting.
– Rudi Visser
Mar 22 at 9:59
add a comment |
2 Answers
2
active
oldest
votes
You can derive from NavigationPage reference.
public class CustomNavigationPage : NavigationPage
//You can define your container here.
public CustomNavigationPage()
//You can resolve here
and also you can look
here
add a comment |
I Can think of a better way You are using Autofac so you can have a generic method that can help the cause.
public static async Task NavigateAsync<TContentPage>(INavigation navigation ) where TContentPage : ContentPage
var contentPage = App.Container.Resolve<TContentPage>();
await navigation.PushAsync(contentPage, true);
Also If you need to pass a parameter You can modify it like this
public static async Task NavigateAsync<TContentPage, TNavigationParameter>(INavigation navigation,
TNavigationParameter navParam,
Action<TContentPage, TNavigationParameter> action = null) where TContentPage : ContentPage
var contentPage = App.Container.Resolve<TContentPage>();
action?.Invoke(contentPage, navParam);
await navigation.PushAsync(contentPage, true);
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55280008%2fneed-to-overide-the-navigation-method%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can derive from NavigationPage reference.
public class CustomNavigationPage : NavigationPage
//You can define your container here.
public CustomNavigationPage()
//You can resolve here
and also you can look
here
add a comment |
You can derive from NavigationPage reference.
public class CustomNavigationPage : NavigationPage
//You can define your container here.
public CustomNavigationPage()
//You can resolve here
and also you can look
here
add a comment |
You can derive from NavigationPage reference.
public class CustomNavigationPage : NavigationPage
//You can define your container here.
public CustomNavigationPage()
//You can resolve here
and also you can look
here
You can derive from NavigationPage reference.
public class CustomNavigationPage : NavigationPage
//You can define your container here.
public CustomNavigationPage()
//You can resolve here
and also you can look
here
answered Mar 25 at 21:14
BatuhanBatuhan
3923 silver badges14 bronze badges
3923 silver badges14 bronze badges
add a comment |
add a comment |
I Can think of a better way You are using Autofac so you can have a generic method that can help the cause.
public static async Task NavigateAsync<TContentPage>(INavigation navigation ) where TContentPage : ContentPage
var contentPage = App.Container.Resolve<TContentPage>();
await navigation.PushAsync(contentPage, true);
Also If you need to pass a parameter You can modify it like this
public static async Task NavigateAsync<TContentPage, TNavigationParameter>(INavigation navigation,
TNavigationParameter navParam,
Action<TContentPage, TNavigationParameter> action = null) where TContentPage : ContentPage
var contentPage = App.Container.Resolve<TContentPage>();
action?.Invoke(contentPage, navParam);
await navigation.PushAsync(contentPage, true);
add a comment |
I Can think of a better way You are using Autofac so you can have a generic method that can help the cause.
public static async Task NavigateAsync<TContentPage>(INavigation navigation ) where TContentPage : ContentPage
var contentPage = App.Container.Resolve<TContentPage>();
await navigation.PushAsync(contentPage, true);
Also If you need to pass a parameter You can modify it like this
public static async Task NavigateAsync<TContentPage, TNavigationParameter>(INavigation navigation,
TNavigationParameter navParam,
Action<TContentPage, TNavigationParameter> action = null) where TContentPage : ContentPage
var contentPage = App.Container.Resolve<TContentPage>();
action?.Invoke(contentPage, navParam);
await navigation.PushAsync(contentPage, true);
add a comment |
I Can think of a better way You are using Autofac so you can have a generic method that can help the cause.
public static async Task NavigateAsync<TContentPage>(INavigation navigation ) where TContentPage : ContentPage
var contentPage = App.Container.Resolve<TContentPage>();
await navigation.PushAsync(contentPage, true);
Also If you need to pass a parameter You can modify it like this
public static async Task NavigateAsync<TContentPage, TNavigationParameter>(INavigation navigation,
TNavigationParameter navParam,
Action<TContentPage, TNavigationParameter> action = null) where TContentPage : ContentPage
var contentPage = App.Container.Resolve<TContentPage>();
action?.Invoke(contentPage, navParam);
await navigation.PushAsync(contentPage, true);
I Can think of a better way You are using Autofac so you can have a generic method that can help the cause.
public static async Task NavigateAsync<TContentPage>(INavigation navigation ) where TContentPage : ContentPage
var contentPage = App.Container.Resolve<TContentPage>();
await navigation.PushAsync(contentPage, true);
Also If you need to pass a parameter You can modify it like this
public static async Task NavigateAsync<TContentPage, TNavigationParameter>(INavigation navigation,
TNavigationParameter navParam,
Action<TContentPage, TNavigationParameter> action = null) where TContentPage : ContentPage
var contentPage = App.Container.Resolve<TContentPage>();
action?.Invoke(contentPage, navParam);
await navigation.PushAsync(contentPage, true);
answered Jun 5 at 3:48
Ishara LakshithaIshara Lakshitha
1539 bronze badges
1539 bronze badges
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55280008%2fneed-to-overide-the-navigation-method%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
What are you trying to achieve here? Most apps would introduce a service dedicated to navigation, that would wire in your DI that way rather than hacking the NavigationPage's Navigation itself.
– Rudi Visser
Mar 21 at 22:04
I don't need to any framework. in this case I need to create my own navigation system using di can it possible
– ish1104
Mar 22 at 3:23
I'm not suggesting a framework, I'm suggesting a service dedicated to navigation, rather than calling straight onto the Navigation object itself. Take a look at Enterprise App Navigation from Microsoft that should describe better what I'm suggesting.
– Rudi Visser
Mar 22 at 9:59