public AdditionalChoose(List <object> items, string title, bool multipleSelection = false) { _multipleSelection = multipleSelection; InitializeComponent(); Titlelabel.Content = title; Items = items; foreach (object item in Items) { AdditionalChooseItem chooseItem = new AdditionalChooseItem(item); chooseItem.Click += ChooseItem_Click; _chooseItems.Add(chooseItem); ItemsPanel.Children.Add(chooseItem); } ReadyButton.Clicked += (s, ea) => { ReadyButtonClicked?.Invoke(this, EventArgs.Empty); }; CancelButton.Clicked += (s, ea) => { CancelButtonClicked?.Invoke(this, EventArgs.Empty); }; }
private void ChooseItem_Click(object sender, EventArgs e) { AdditionalChooseItem item = (AdditionalChooseItem)sender; if (_multipleSelection) { item.Selected = !item.Selected; } else { _chooseItems.ForEach(obj => obj.Selected = false); item.Selected = true; SelectedItems.Clear(); } SelectedItems.Add(item.Object); }