예제 #1
0
        public CubeItemViewModel(BaseViewModel parentViewModel, CubeItemModel dataModel, IDialogService dialogService)
            : base(parentViewModel)
        {
            Contract.Requires(dialogService != null);
            _dialogService = dialogService;
            _dataModel     = dataModel;

            Func <InventoryEditorModel, InventoryEditorViewModel>   viewModelCreator  = model => new InventoryEditorViewModel(this, model);
            Func <ObservableCollection <InventoryEditorViewModel> > collectionCreator =
                () => new ObservableViewModelCollection <InventoryEditorViewModel, InventoryEditorModel>(dataModel.Inventory, viewModelCreator);

            _inventory = new Lazy <ObservableCollection <InventoryEditorViewModel> >(collectionCreator);

            _dataModel.PropertyChanged += delegate(object sender, PropertyChangedEventArgs e)
            {
                if (e.PropertyName == "Inventory")
                {
                    collectionCreator.Invoke();
                    _inventory = new Lazy <ObservableCollection <InventoryEditorViewModel> >(collectionCreator);
                }
                // Will bubble property change events from the Model to the ViewModel.
                OnPropertyChanged(e.PropertyName);
            };
        }
예제 #2
0
 public CubeItemViewModel(BaseViewModel parentViewModel, CubeItemModel dataModel)
     : this(parentViewModel, dataModel, ServiceLocator.Resolve <IDialogService>())
 {
 }
예제 #3
0
 public bool ConvertFromHeavyToLightArmor()
 {
     return(CubeItemModel.ConvertFromHeavyToLightArmor(_dataModel.Cube));
 }