Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Need to Modifify the navigation method in order to have more navigation than one

$
0
0

My navigation method in the base abstract class

          public abstract void Navigate(SelectedItemChangedEventArgs e); '

In one of my View classes, I need to have more than one navigation when some button clicked or tapped. using my navigate function only I can use for one navigation I need to improve the navigate method to have improved so it can use for multiple navigations. I am a little clueless here what should I do do a relay command or use generic. what I need to change in order to use this method for multiple navigation purposes

  private void JournalSelected(object sender, SelectedItemChangedEventArgs e)
 {
    if (e?.SelectedItem == null) return;
    JournalGroupList.SelectedItem = null;
    Navigate(e);
 }

public override async void Navigate(SelectedItemChangedEventArgs e)
{
    JournalHistoryViewPage journalHistoryViewPage = App.Container.Resolve<JournalHistoryViewPage>();
    journalHistoryViewPage.BaseViewModel.JournalGroup = e.SelectedItem as JournalGroup;
    journalHistoryViewPage.BaseViewModel.SelectedPatient = BaseViewModel.SelectedPatient;
    await Navigation.PushAsync(journalHistoryViewPage, true);
}

 private async void VitalSigns_Tapped(object sender, System.EventArgs e)
 {
    var vitalSignsViewPage = App.Container.Resolve<VitalSignsViewPage>();
    vitalSignsViewPage.BaseViewModel.SelectedPatient = BaseViewModel.SelectedPatient;
    await Navigation.PushAsync(vitalSignsViewPage, true);
}

As I used Navigate Function in journalselected I also need it to use for VitalSigns_tapped. In here I feel like I have duplicated the code and did not use the method properly


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>