-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNavigationServiceDemoViewModel.cs
38 lines (33 loc) · 1.54 KB
/
NavigationServiceDemoViewModel.cs
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
namespace MvvmDemo.Modules.NavigationServiceDemo;
public class NavigationServiceDemoViewModel : DXObservableObject {
public int NavigationParameter { get => navigationParameter; set => SetProperty(ref navigationParameter, value); }
public bool ShowModal { get => showModal; set => SetProperty(ref showModal, value); }
public string? CurrentLocation { get => currentLocation; private set => SetProperty(ref currentLocation, value); }
public int InstanceNumber { get; private set; }
public RelayCommand ShowDetailFormCommand { get; }
public RelayCommand OnNavigatedToCommand { get; }
INavigationService NavigationService { get; }
public NavigationServiceDemoViewModel(INavigationService navigationService) {
this.navigationParameter = 5;
this.showModal = false;
NavigationService = navigationService;
ShowDetailFormCommand = new RelayCommand(ShowDetailForm);
OnNavigatedToCommand = new RelayCommand(OnNavigatedTo);
InstanceNumber = ++instanceNumber;
}
void ShowDetailForm() {
var parameters = new Dictionary<string, object>();
parameters["NavigationParameter"] = NavigationParameter;
parameters["IsModal"] = ShowModal;
NavigationService.GoToAsync(
ModuleInfos.NavigationServiceDetailPage.Route,
parameters);
}
void OnNavigatedTo() {
CurrentLocation = NavigationService.CurrentLocation;
}
int navigationParameter;
bool showModal;
string? currentLocation;
static int instanceNumber;
}