public override void BindStateToControlProperties() { _userControl.BindStateToControlProperties(); if (_userControl.SelectedObjects.Any()) { if (_userControl.SelectedObjects.Count() > 1) { throw new InvalidOperationException("Multiple elements selected. This was not expedted."); } this.Selected = _userControl.SelectedObjects.First(); } else { this.Selected = null; } }
public override void BindStateToControlProperties() { _userControl.BindStateToControlProperties(); if (this.Selected is IList) { IList listCopy = (IList)Activator.CreateInstance(this.Selected.GetType()); foreach (object selectedElement in _userControl.SelectedObjects) { listCopy.Add(selectedElement); } this.Selected = listCopy; } else { this.Selected = _userControl.SelectedObjects; this.SelectedAsString = string.Join(",", _userControl.SelectedKeys.ToArray()); // add code here that populate SelectedAsString } }