using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Linq; using System.Web.UI.WebControls; using System.Windows; using System.Windows.Documents; using System.Windows.Input; using BeWo.Annotations; using BS.Shared; using BS.Shared.Core; using BS.Shared.Extensions; namespace BeWo.View.Controls { public partial class ListboxSelectControl { public event Action CancelButtonClicked; public event Action SelectButtonClicked; public ListboxSelectControl(List items) { InitializeComponent(); if (!items.Any()) throw new ArgumentOutOfRangeException(); Listbox.ItemsSource = items; Listbox.SelectedItem = items.First(); } public List Items => Listbox.ItemsSource as List; public object SelectedItem => Listbox.SelectedItem; private void CancelButton_Click(object sender, RoutedEventArgs e) { CancelButtonClicked?.Invoke(); } private void SelectButton_Click(object sender, RoutedEventArgs e) { SelectButtonClicked?.Invoke(); } private void Listbox_OnMouseDoubleClick(object sender, MouseButtonEventArgs e) { SelectButtonClicked?.Invoke(); } } }