/// <summary> /// constructor takes server in arguments /// </summary> /// <param name="Server"></param> public VMInnerDecks(Network Server) { _Server = Server; VMDecks decks = new VMDecks(Server); decks.moveTo += new EventHandler<MoveToEventArgs>(Inner_moveTo); VMBuilding building = new VMBuilding(Server); building.moveTo += new EventHandler<MoveToEventArgs>(Inner_moveTo); ViewModels = new ObservableCollection<ViewModelBase>() { decks, building }; ViewModelView = CollectionViewSource.GetDefaultView(ViewModels); }
protected override void OnBindingContextChanged(VMBase oldViewModel, VMBase newViewModel) { base.OnBindingContextChanged(oldViewModel, newViewModel); VMBuilding oldVm = oldViewModel as VMBuilding; if (oldVm != null) { oldVm.Name.OnValueChanged -= NameChanged; oldVm.TileId.OnValueChanged -= TileIdChanged; } if (ViewModel != null) { ViewModel.Name.OnValueChanged += NameChanged; ViewModel.TileId.OnValueChanged += TileIdChanged; } }
public MBuilding() { viewModel = new VMBuilding(); }