Files
laatzen/Common/OmniPlus/InspectionUI/Plugins/ItemsGridCellDropdownVM.cs
T

39 lines
1006 B
C#

namespace InspectionUI
{
using InspectionUI.Abstraction.Interfaces;
using System;
using System.Collections.ObjectModel;
public class ItemsGridCellDropdownVM : ItemsGridCellVM, IGridCellDropdown
{
public ItemsGridCellDropdownVM() : base()
{
}
public Action ItemSelected { private get; set; }
private int selectedIndex;
public int SelectedIndex
{
get => this.selectedIndex;
set => this.Set(() => this.selectedIndex = value);
}
private object selectedItem;
public object SelectedItem
{
get => this.selectedItem ?? (this.ItemsSource?.Count > 0 ? this.ItemsSource[0] : null);
set
{
this.Set(() => this.selectedItem = value);
this.ItemSelected?.Invoke();
}
}
public ObservableCollection<object> ItemsSource { get; }
= new ObservableCollection<object>();
}
}