private void msyslogin_click(Object sender, EventArgs e) { List <SidebarItem> sidebarItems = new List <SidebarItem>(); SidebarItem sidebaritem = new SidebarItem(); sidebaritem.title = "功能集"; sidebaritem.subitems = new List <SidebarItem_Struct>(); sidebaritem.subitems.Add(new SidebarItem_Struct("功能", "SIBEBARTESTFUN", 0)); sidebaritem.subitems.Add(new SidebarItem_Struct("功能", "SIBEBARTESTFUN", 0)); sidebaritem.t = this; // public static function : null // public function : this // NameSpace.RD_Class.GetInstance(this.ParentForm); sidebaritem.atype = Type.GetType("studmain.Form1"); sidebaritem.next = new List <SidebarItem>(); SidebarItem subsi = new SidebarItem(); subsi.title = "功能集"; subsi.subitems = new List <SidebarItem_Struct>(); subsi.subitems.Add(new SidebarItem_Struct("功能", "SIBEBARTESTFUN", 0)); subsi.subitems.Add(new SidebarItem_Struct("功能", "SIBEBARTESTFUN", 0)); subsi.t = this; subsi.atype = Type.GetType("studmain.Form1"); sidebaritem.next.Add(subsi); sidebarItems.Add(sidebaritem); Sidebar <Form1> sidebar_binding = new Sidebar <Form1>(this, sidebar, listView1, imageList1, sidebarItems); }
public SidebarPage(ShieldPageViewModel vm) { InitializeComponent(); menuList = new List <SidebarItem>(); NavigationPage.SetHasNavigationBar(this, false); ViewModel = vm; var page1 = new SidebarItem() { Id = "profile", Title = "Profile", Icon = "ic_user.png" }; var page2 = new SidebarItem() { Id = "device", Title = "Device", Icon = "ic_settings.png" }; var page3 = new SidebarItem() { Id = "chart", Title = "Chart", Icon = "ic_chart.png" }; var page4 = new SidebarItem() { Id = "about", Title = "About", Icon = "ic_help.png" }; // Adding menu items to menuList menuList.Add(page1); menuList.Add(page2); menuList.Add(page3); menuList.Add(page4); lst.ItemsSource = menuList; }
public SidebarItemViewModel(SidebarItem sidebarItem) { Icon = sidebarItem.Icon.FirstOrDefault(); Title = sidebarItem.Title; SidebarItemLocation = sidebarItem.Location.FirstOrDefault().ToEnum <SidebarItemLocationEnum>(); if (sidebarItem.Type.FirstOrDefault() is MultipleChoiceOption sidebarItemType) { SidebarItemType = sidebarItemType.ToEnum <SidebarItemTypeEnum>(); } }
private void lst_ItemSelected(object sender, SelectedItemChangedEventArgs e) { try { SidebarItem item = e.SelectedItem as SidebarItem; if (item != null) { switch (item.Id) { case "profile": Application.Current.MainPage.Navigation.PushAsync(new ProfilePage(true)); PopupNavigation.Instance.PopAsync(); break; case "device": App.OpenBluetoothSettingsAsync(); PopupNavigation.Instance.PopAsync(); break; case "about": Application.Current.MainPage.Navigation.PushAsync(new AboutPage()); PopupNavigation.Instance.PopAsync(); break; case "chart": Application.Current.MainPage.Navigation.PushAsync(new ChartPage(ViewModel)); PopupNavigation.Instance.PopAsync(); break; default: break; } } } catch (Exception ex) { } }