/// <summary> /// Draws alarm list /// </summary> /// <returns>Returns RelativeLayout</returns> protected virtual StackLayout Draw() { /// Need to get bindable context to assign list value AlarmRecord alarmData = (AlarmRecord)BindingContext; /// If binding context is null, can't proceed further action if (alarmData == null) { return(null); } /// Alarm item layout should be set if null if (alarmItemLayout == null) { // The layout of item cell alarmItemLayout = new StackLayout { HeightRequest = 120, Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand }; // Time Label timeLabel = new Label() { WidthRequest = 280, FontSize = 12, TextColor = Color.White, HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, HorizontalTextAlignment = TextAlignment.Center, VerticalTextAlignment = TextAlignment.Center, }; timeLabel.SetBinding(Label.TextProperty, new Binding("ScheduledDateTime", BindingMode.Default, new ScheduledDateTimeToTextConverter())); alarmItemLayout.Children.Add(timeLabel); switchObj = new Check { HeightRequest = 80, WidthRequest = 80, DisplayStyle = CheckDisplayStyle.Default, IsToggled = alarmData.AlarmState == AlarmStates.Inactive ? false : true, HorizontalOptions = LayoutOptions.End, VerticalOptions = LayoutOptions.Center, }; alarmItemLayout.Children.Add(switchObj); /// Adds an event switchObj.Toggled += (s, e) => { AlarmRecord am = (AlarmRecord)BindingContext; if (am != null) { /// Modify state and re-draw it. Redraw must be called to redraw if (e.Value) { AlarmModel.ReactivatelAlarm(am); } else { AlarmModel.DeactivatelAlarm(am); } } }; } return(alarmItemLayout); }