-
Notifications
You must be signed in to change notification settings - Fork 1
/
ViewModel.cs
57 lines (51 loc) · 2.32 KB
/
ViewModel.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using DevExpress.Mvvm;
using System.Collections.ObjectModel;
using System;
namespace Hamburger.ViewModel {
public class MainViewModel : NavigationViewModelBase {
public HamburgerMenuItemViewModel SelectedItem {
get { return GetProperty(() => SelectedItem); }
set { SetProperty(() => SelectedItem, value); }
}
public bool IsMenuVisible {
get { return GetProperty(() => IsMenuVisible); }
set { SetProperty(() => IsMenuVisible, value); }
}
public ObservableCollection<HamburgerMenuItemViewModel> Items {
get { return GetProperty(() => Items); }
set { SetProperty(() => Items, value); }
}
public ObservableCollection<HamburgerSubMenuItemViewModel> SubItems
{
get { return GetProperty(() => SubItems); }
set { SetProperty(() => SubItems, value); }
}
INavigationService NavigationService { get { return GetService<INavigationService>(); } }
public MainViewModel() {
Items = new ObservableCollection<HamburgerMenuItemViewModel>();
Items.Add(new HamburgerSubMenuItemViewModel("Main Page", typeof(MainPage)) {
SubItems = new ObservableCollection<HamburgerSubMenuItemViewModel>() {
new HamburgerSubMenuItemViewModel("SubMenu1", typeof(MainPage)),
new HamburgerSubMenuItemViewModel("SubMenu", typeof(MainPage_SubPage))
}
});
Items.Add(new HamburgerMenuItemViewModel("Simple Page", typeof(SimplePage)));
SelectedItem = Items[0];
IsMenuVisible = true;
}
}
public class HamburgerMenuItemViewModel : ISupportParentViewModel {
public string Caption { get; set; }
public Type PageName { get; set; }
public ObservableCollection<HamburgerSubMenuItemViewModel> SubItems { get; internal set; }
public object ParentViewModel { get; set; }
public HamburgerMenuItemViewModel(string caption, Type pageName) {
Caption = caption;
PageName = pageName;
}
}
public class HamburgerSubMenuItemViewModel : HamburgerMenuItemViewModel
{
public HamburgerSubMenuItemViewModel(string caption, Type pageName) : base(caption, pageName) {}
}
}