-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathBaseNavigationViewModel.cs
More file actions
42 lines (36 loc) · 1.22 KB
/
BaseNavigationViewModel.cs
File metadata and controls
42 lines (36 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using Lemon.ModuleNavigation.Abstractions;
using ReactiveUI;
using System.Diagnostics;
using System.Reactive;
namespace Lemon.ModuleNavigation.SampleViewModel;
public class BaseNavigationViewModel : ReactiveObject, INavigationAware, ICanUnload
{
public virtual string Greeting => $"Welcome to {GetType().Name}[{Environment.ProcessId}][{Environment.CurrentManagedThreadId}]{Environment.NewLine}{DateTime.Now:yyyy-MM-dd HH-mm-ss.ffff}";
public virtual string? Alias => GetType().Name;
public BaseNavigationViewModel()
{
UnloadViewCommand = ReactiveCommand.Create(() =>
{
var code = this.GetHashCode();
Debug.WriteLine(code);
RequestUnload?.Invoke();
});
}
public ReactiveCommand<Unit,Unit> UnloadViewCommand
{
get;
}
public event Action? RequestUnload;
public virtual bool IsNavigationTarget(NavigationContext navigationContext)
{
return true;
}
public virtual void OnNavigatedFrom(NavigationContext navigationContext)
{
//throw new NotImplementedException();
}
public virtual void OnNavigatedTo(NavigationContext navigationContext)
{
//throw new NotImplementedException();
}
}