protected void ShowHideElements() { if (MainCalendars.Count < 1) { return; } ContentView.Children.Clear(); dayLabels.Clear(); for (var i = 0; i < ShowNumOfMonths; i++) { var main = MainCalendars[i] as Layout; if (ShowInBetweenMonthLabels && i > 0) { var label = new Label { FontSize = TitleLabel.FontSize, VerticalTextAlignment = TitleLabel.VerticalTextAlignment, HorizontalTextAlignment = TitleLabel.HorizontalTextAlignment, FontAttributes = TitleLabel.FontAttributes, TextColor = TitleLabel.TextColor, HorizontalOptions = LayoutOptions.FillAndExpand, Text = "" }; if (TitleLabels == null) { TitleLabels = new List <Label>(ShowNumOfMonths); } TitleLabels.Add(label); /*if (i == ShowNumOfMonths - 1) * { * MonthNavigationLayout.Children.Remove(TitleRightArrow); * ContentView.Children.Add(new StackLayout { * Orientation = StackOrientation.Horizontal, * Padding = new Thickness(TitleLeftArrow.FontSize*1.5,0,0,0), Children = { label, TitleRightArrow } * }); * } * else * {*/ ContentView.Children.Add(label); //} } if (ShowNumberOfWeek) { main = new StackLayout { Padding = 0, Spacing = 0, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Orientation = StackOrientation.Horizontal, Children = { WeekNumbers[i], MainCalendars[i] } }; } if (WeekdaysShow) { var columDef = new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }; var dl = new Grid { VerticalOptions = LayoutOptions.Start, RowSpacing = 0, ColumnSpacing = 0, Padding = 0 }; dl.ColumnDefinitions = new ColumnDefinitionCollection { columDef, columDef, columDef, columDef, columDef, columDef, columDef }; var marginFront = NumberOfWeekFontSize * 1.5; if (ShowNumberOfWeek) { dl.Padding = new Thickness(marginFront, 0, 0, 0); } for (int c = 0; c < 7; c++) { dayLabels.Add(new Label { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalTextAlignment = TextAlignment.Center, VerticalTextAlignment = TextAlignment.Center, BackgroundColor = WeekdaysBackgroundColor, TextColor = WeekdaysTextColor, FontSize = WeekdaysFontSize, FontFamily = WeekdaysFontFamily, FontAttributes = WeekdaysFontAttributes }); dl.Children.Add(dayLabels.Last(), c, 0); } var stack = new StackLayout { Padding = 0, Spacing = 0, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Orientation = StackOrientation.Vertical, Children = { dl, main } }; ContentView.Children.Add(stack); } else { ContentView.Children.Add(main); } } }
protected void ShowHideElements() { if (MainCalendars.Count < 1) { return; } ContentView.Children.Clear(); dayLabels.Clear(); for (var i = 0; i < ShowNumOfMonths; i++) { var main = MainCalendars[i] as Layout; if (ShowInBetweenMonthLabels && i > 0) { var label = new Label { FontSize = TitleLabel.FontSize, VerticalTextAlignment = TitleLabel.VerticalTextAlignment, HorizontalTextAlignment = TitleLabel.HorizontalTextAlignment, FontAttributes = TitleLabel.FontAttributes, TextColor = TitleLabel.TextColor, HorizontalOptions = LayoutOptions.FillAndExpand, Text = string.Empty }; if (TitleLabels == null) { TitleLabels = new List <Label>(ShowNumOfMonths); } TitleLabels.Add(label); ContentView.Children.Add(label); } if (ShowNumberOfWeek) { main = new StackLayout { Padding = 0, Spacing = 0, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Orientation = StackOrientation.Horizontal, Children = { WeekNumbers[i], MainCalendars[i] } }; } if (WeekdaysShow) { var columDef = new ColumnDefinition { Width = Device.Idiom == TargetIdiom.Tablet ? 80 : 40 }; var dl = new Grid { VerticalOptions = LayoutOptions.CenterAndExpand, RowSpacing = 0, ColumnSpacing = 0, Padding = 0 }; dl.ColumnDefinitions = new ColumnDefinitionCollection { columDef, columDef, columDef, columDef, columDef, columDef, columDef }; var marginFront = NumberOfWeekFontSize * 1.5; if (Device.RuntimePlatform == Device.UWP) { marginFront = NumberOfWeekFontSize * 3; } if (ShowNumberOfWeek) { dl.Padding = new Thickness(marginFront, 0, 0, 0); } for (int c = 0; c < 7; c++) { dayLabels.Add(new Label { HeightRequest = (Device.Idiom == TargetIdiom.Tablet ? 70 : 30), HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, HorizontalTextAlignment = TextAlignment.Center, VerticalTextAlignment = TextAlignment.Center, BackgroundColor = WeekdaysBackgroundColor, TextColor = WeekdaysTextColor, FontSize = WeekdaysFontSize, FontFamily = WeekdaysFontFamily, FontAttributes = WeekdaysFontAttributes }); dl.Children.Add(dayLabels.Last(), c, 0); } var stack = new StackLayout { Padding = 0, Spacing = 0, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.Center, Orientation = StackOrientation.Vertical, Children = { dl, main } }; ContentView.Children.Add(stack); } else { ContentView.Children.Add(main); } } }