-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add outputs for NavigationInterfaces
- Loading branch information
Showing
2 changed files
with
52 additions
and
12 deletions.
There are no files selected for viewing
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
59 changes: 52 additions & 7 deletions
59
Sandbox/Xamarin/HelloWorld/HelloWorld/HelloWorld/ViewModels/ViewModelBase.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,69 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using Prism; | ||
using Prism.AppModel; | ||
using Prism.Mvvm; | ||
using Prism.Navigation; | ||
|
||
namespace HelloWorld.ViewModels | ||
{ | ||
public class ViewModelBase : BindableBase, INavigationAware | ||
public class ViewModelBase : BindableBase, INavigationAware, IInitialize, IInitializeAsync, IDestructible, IConfirmNavigation, IConfirmNavigationAsync, IPageLifecycleAware, IActiveAware | ||
{ | ||
public virtual void OnNavigatedFrom(INavigationParameters parameters) | ||
private bool active; | ||
public bool IsActive | ||
{ | ||
|
||
get => active; | ||
set => SetProperty(ref active, value, () => Console.WriteLine($"{GetType().Name}: IsActive: {value}")); | ||
} | ||
|
||
public virtual void OnNavigatedTo(INavigationParameters parameters) | ||
public event EventHandler IsActiveChanged; | ||
|
||
public bool CanNavigate(INavigationParameters parameters) | ||
{ | ||
Console.WriteLine($"{GetType().Name}: {nameof(CanNavigate)}"); | ||
return true; | ||
} | ||
|
||
public Task<bool> CanNavigateAsync(INavigationParameters parameters) | ||
{ | ||
Console.WriteLine($"{GetType().Name}: {nameof(CanNavigateAsync)}"); | ||
return Task.FromResult(true); | ||
} | ||
|
||
public void Destroy() | ||
{ | ||
Console.WriteLine($"{GetType().Name}: {nameof(Destroy)}"); | ||
} | ||
|
||
public void Initialize(INavigationParameters parameters) | ||
{ | ||
Console.WriteLine($"{GetType().Name}: {nameof(Initialize)}"); | ||
} | ||
|
||
public Task InitializeAsync(INavigationParameters parameters) | ||
{ | ||
|
||
Console.WriteLine($"{GetType().Name}: {nameof(InitializeAsync)}"); | ||
return Task.CompletedTask; | ||
} | ||
|
||
public virtual void OnNavigatingTo(INavigationParameters parameters) | ||
public void OnAppearing() | ||
{ | ||
Console.WriteLine($"{GetType().Name}: {nameof(OnAppearing)}"); | ||
} | ||
|
||
public void OnDisappearing() | ||
{ | ||
Console.WriteLine($"{GetType().Name}: {nameof(OnDisappearing)}"); | ||
} | ||
|
||
public virtual void OnNavigatedFrom(INavigationParameters parameters) | ||
{ | ||
Console.WriteLine($"{GetType().Name}: {nameof(OnNavigatedFrom)}"); | ||
} | ||
|
||
public virtual void OnNavigatedTo(INavigationParameters parameters) | ||
{ | ||
|
||
Console.WriteLine($"{GetType().Name}: {nameof(OnNavigatedTo)}"); | ||
} | ||
} | ||
} |