public MainPage() : base(PanelSetEnum.psLeftRight) { #region right menu var btnRightMenuShow = new Button { Text = "Right menu show", }; btnRightMenuShow.Clicked += (s, e) => { IsShowRightPanel = !IsShowRightPanel; }; //add button to main layout on page ContentLayout.Children.Add(btnRightMenuShow); //set width for right panel RightPanelWidth = 150; //add label to main layout on right panel RightPanel.AddToContext( new StackLayout { Padding = new Thickness(32), Children = { new Label { Text = "right menu", TextColor = Color.Red, } } }); RightPanel.BackgroundColor = Color.Blue; #endregion #region left menu var btnLeftMenuShow = new Button { Text = "Left menu show", }; btnLeftMenuShow.Clicked += (s, e) => { IsShowLeftPanel = !IsShowLeftPanel; }; ContentLayout.Children.Add(btnLeftMenuShow); LeftPanel.BackgroundColor = Color.Yellow; LeftPanel.AddToContext( new StackLayout { Padding = new Thickness(32), Children = { new Label { Text = "left menu", TextColor = Color.Green, } } }); #endregion }
public MainPage() : base(typeof(MainViewModel), typeof(MainContentUI), PanelSetEnum.psLeftRight) { BackgroundColor = (Color)App.Current.Resources[MainStyles.ListBackgroundColor]; var appBar = new TitleBar(this, TitleBar.BarBtnEnum.bbLeftRight, TitleBar.BarAlignEnum.baBottom) { BarColor = Color.Transparent, HorizontalOptions = LayoutOptions.FillAndExpand }; appBar.BtnRight.BackgroundColor = new Color(255, 255, 255, 0); appBar.BtnRight.Source = contentUI.IconMenuSideBar; appBar.BtnRight.Click += viewModel.AppBar_BtnRightClick; appBar.BtnLeft.BackgroundColor = new Color(255, 255, 255, 0); appBar.BtnLeft.Source = contentUI.IconFilter; appBar.BtnLeft.Click += viewModel.AppBar_BtnLeftClick; RightPanel.BackgroundColor = (Color)App.Current.Resources[MainStyles.MainBackgroundColor]; RightPanel.Opacity = 0.9; SpeedAnimatePanel = 200; LeftPanel.BackgroundColor = (Color)App.Current.Resources[MainStyles.MainBackgroundColor]; LeftPanel.Opacity = 0.9; MapLocation = new MapTile { HasScrollEnabled = true, HasZoomEnabled = true, Context = contentUI, }; MapLocation.ClickPinDetail += viewModel.MapLocation_ClickPinDetail; var btnLocation = new ImageButton(); btnLocation.HeightRequest = appBar.HeightBar; btnLocation.WidthRequest = appBar.HeightBar; btnLocation.BackgroundColor = new Color(255, 255, 255, 0); btnLocation.Source = contentUI.IconLocation; btnLocation.Click += viewModel.BtnLocation_Click; var mainLayout = new RelativeLayout(); mainLayout.Children.Add(MapLocation.MapLayout, Constraint.Constant(0), Constraint.Constant(0), Constraint.RelativeToParent(parent => { return(parent.Width); }), Constraint.RelativeToParent(parent => { return(parent.Height); })); mainLayout.Children.Add(appBar, Constraint.Constant(0), Constraint.RelativeToParent(parent => { return(parent.Height - appBar.HeightBar); }), Constraint.RelativeToParent(parent => { return(parent.Width); }), Constraint.Constant(appBar.HeightBar)); mainLayout.Children.Add(btnLocation, Constraint.Constant(0), Constraint.RelativeToView(appBar, (parent, sibling) => { return(sibling.Y - appBar.HeightBar - 10); })); ContentLayout.Children.Add(mainLayout); PanelChanged += (s, e) => { if (e.IsShow) { MapLocation.CloseDetailInfo(); } }; #region Right SideBar menu RightPanel.ClearContext(); RightPanel.AddToContext(new BoxView { BackgroundColor = Color.Transparent, HeightRequest = 50, }); var imgLogo = new Image { Source = ImageSource.FromFile(contentUI.ImgLogo), HeightRequest = Device.OnPlatform(-1, -1, 120), }; RightPanel.AddToContext(imgLogo); RightPanel.AddToContext(new BoxView { BackgroundColor = Color.Transparent, HeightRequest = 50, }); var menuView = new ListViewExtended(); menuView.SetBinding(ListView.ItemsSourceProperty, "MenuItemList"); menuView.RowHeight = Device.OnPlatform(48, 48, 72); menuView.SeparatorVisibility = SeparatorVisibility.None; menuView.ItemTemplate = new DataTemplate(() => new MenuViewTemplate()); menuView.ItemSelected += viewModel.OnMenuViewItemTapped; menuView.IsScrollable = false; RightPanel.AddToContext(menuView, false); #endregion #region Left SideBar menu LeftPanel.ClearContext(); LeftPanel.AddToContext(new BoxView { BackgroundColor = Color.Transparent, HeightRequest = 50, }); var filterView = new ListViewExtended(); filterView.IsScrollable = false; filterView.SetBinding(ListView.ItemsSourceProperty, "FilterCategoryList"); filterView.RowHeight = Device.OnPlatform(48, 48, 72); filterView.SeparatorVisibility = SeparatorVisibility.None; filterView.ItemTemplate = new DataTemplate(() => new FilterViewTemplate(viewModel)); filterView.ItemSelected += viewModel.OnMenuViewItemTapped; LeftPanel.AddToContext(filterView, false); #endregion }