public WareGroupTreeViewWrapper(WareGroup wareGroup, Action<WareGroupTreeViewWrapper> onEdit, Action<WareGroupTreeViewWrapper> onSelect, WareGroupTreeViewWrapper parent)
        {
            _wareGroup = wareGroup;
            _parent = parent;
            OnEdit = onEdit;
            OnSelect = onSelect;

            _children = new ObservableCollection<WareGroupTreeViewWrapper>(
                (from child in _wareGroup.Children
                 select new WareGroupTreeViewWrapper(child, onEdit, onSelect, this))
                 );
        }
 public virtual void SetUp(Func<WareGroupTreeViewWrapper>getSelected,IWareGroupModel wareGroupModel)
 {
     if (getSelected == null) throw new ArgumentNullException("getSelected");
     if (wareGroupModel == null) throw new ArgumentNullException("wareGroupModel");
     var waregroup = getSelected();
     if (waregroup==null) throw new ArgumentException("Ничего не выбрано");
     _wareGroup = waregroup;
     _parentBeforeSave = _wareGroup.Parent;
     _getSelected = getSelected;
     _wareGroupModel = wareGroupModel;
 }
        IEnumerable<WareGroupTreeViewWrapper> FindMatches(string searchText, WareGroupTreeViewWrapper person)
        {
            if (person.WareGroup.Name.Contains(searchText))
                yield return person;

            foreach (WareGroupTreeViewWrapper child in person.Children)
                foreach (WareGroupTreeViewWrapper match in this.FindMatches(searchText, child))
                    yield return match;
        }
 private void AddNewWareGroup()
 {
     var newWareGroup = _wareGroupModel.CreateWareGroup();
     var newWrapper = new WareGroupTreeViewWrapper(newWareGroup, (e => EditWareGroup = e),
                                                   (e => CurrentSelectedWareGroup = e), CurrentSelectedWareGroup);
     if (CurrentSelectedWareGroup == null)
     {
         WareGroups.Add(newWrapper);
     }
     else
     {
         newWareGroup.Parent = CurrentSelectedWareGroup.WareGroup;
         CurrentSelectedWareGroup.Children.Add(newWrapper);
     }
     CurrentSelectedWareGroup = newWrapper;
     EditSelected();
 }