aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.SystemInfo/SystemObjectProperty.cs
blob: c2d04e2a5b5e07fb21883f1eeaf763aff4d379c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;

namespace Tango.SharedUI.Controls
{
    public class MultiSelectListBox : ListBox
    {
        public IList SelectedItemsList
        {
            get { return (IList)GetValue(SelectedItemsListProperty); }
            set { SetValue(SelectedItemsListProperty, value); }
        }

        public static readonly DependencyProperty SelectedItemsListProperty =
            DependencyProperty.Register(nameof(SelectedItemsList), typeof(IList), typeof(MultiSelectListBox), new PropertyMetadata(null));

        public MultiSelectListBox() { }

        protected override void OnSelectionChanged(SelectionChangedEventArgs e)
        {
            base.OnSelectionChanged(e);

            if (SelectedItemsList != null)
            {
                SelectedItemsList.Clear();

                foreach (var item in SelectedItems)
                {
                    SelectedItemsList.Add(item);
                }
            }
        }
    }
}