Created
July 4, 2016 08:11
-
-
Save runceel/8e8bc4ddd09aa4b03a2958f3373cc024 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PageNavigationManager | |
{ | |
public static PageNavigationManager Instance { get; } = new PageNavigationManager(); | |
private INavigation Navigation { get; set; } | |
private Dictionary<string, Type> PageMap { get; } = new Dictionary<string, Type>(); | |
public void Init(INavigation navigation) | |
{ | |
this.Navigation = navigation; | |
} | |
public Task NavigateAsync(string pageName) | |
{ | |
return this.Navigation.PushAsync(Activator.CreateInstance(Type.GetType(this.PageMap[pageName]))); | |
} | |
public void RegisterPage(string pageName, Type pageType) | |
{ | |
this.PageMap[pageName] = pageType; | |
} | |
} | |
// usage | |
// ページに来たときあたりに初期化 | |
PageNavigationManager.Instance.Init(this.Navigation); | |
// アプリの初期化あたりでページの登録 | |
PageNavigationManager.Instance.RegisterPage("HogePage", typeof(HogePage)); | |
PageNavigationManager.Instance.RegisterPage("FugaPage", typeof(FugaPage)); | |
// 画面遷移 | |
await PageNavigationManager.Instance.NavigateAsync("HogePage"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment