/// <summary> /// Create list item with specific conditions. /// </summary> public EmailListItem(EmailList parent, Email s, Color bgColor) { // Set height MinHeight = EmailList.ROW_HEIGHT; HeightRequest = EmailList.ROW_HEIGHT; // Set background color BackgroundColor = DefaultColor = bgColor; // Self expand horizontal and vertical ExpandHorizontal = true; ExpandVertical = true; // No margin at all Margin = 0; // Set parent & active email ListParent = parent; ActiveEmail = s; EmailText = new TextEntry() { Text = s.UserEmail, MarginLeft = 5, HorizontalPlacement = WidgetPlacement.Fill, VerticalPlacement = WidgetPlacement.Center, MarginTop = 1, ExpandHorizontal = true, ExpandVertical = false }; EmailText.Changed += delegate { s.UserEmail = EmailText.Text; if (Email.IsValid(EmailText.Text)) { BackgroundColor = DefaultColor; } else { BackgroundColor = Colors.Red; EmailText.SetFocus(); } }; PackStart(EmailText, true, true); // Error Errors = new CheckBox() { State = (s.Errors) ? CheckBoxState.On : CheckBoxState.Off, WidthRequest = EmailList.ERROR_WIDTH, MinWidth = EmailList.ERROR_WIDTH, HorizontalPlacement = WidgetPlacement.Center, VerticalPlacement = WidgetPlacement.Center, MarginLeft = 25 }; Errors.Toggled += delegate { s.Errors = Errors.State == CheckBoxState.On; }; PackStart(Errors); // Notification Notification = new CheckBox() { State = (s.Notifications) ? CheckBoxState.On : CheckBoxState.Off, WidthRequest = EmailList.ERROR_WIDTH, MinWidth = EmailList.ERROR_WIDTH, HorizontalPlacement = WidgetPlacement.Center, VerticalPlacement = WidgetPlacement.Center }; Notification.Toggled += delegate { s.Notifications = Notification.State == CheckBoxState.On; }; PackStart(Notification); // Button RemoveEmail = new Button(Image.FromResource(DirectorImages.CROSS_ICON)) { HorizontalPlacement = WidgetPlacement.Center, VerticalPlacement = WidgetPlacement.Center, MarginRight = 20 }; RemoveEmail.Clicked += delegate { parent.RemoveEmail(ActiveEmail); }; PackStart(RemoveEmail); }