Files
BeWoPlaner/BeWo/View/Controls/ListboxSelectControl.xaml.cs
Christian 8b8177fcdc cb
2021-10-01 16:49:37 +02:00

53 lines
1.4 KiB
C#

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.DataContracts;
using BS.Shared.Extensions;
namespace BeWo.View.Controls
{
public partial class ListboxSelectControl
{
public event Action CancelButtonClicked;
public event Action SelectButtonClicked;
public ListboxSelectControl(List<object> items)
{
InitializeComponent();
if (!items.Any()) throw new ArgumentOutOfRangeException();
Listbox.ItemsSource = items;
Listbox.SelectedItem = items.First();
}
public List<object> Items => Listbox.ItemsSource as List<object>;
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();
}
}
}