Пример #1
0
        private async void AddEntryBtn_OnClick(object sender, RoutedEventArgs e)
        {
            //#Model-View-Viewmodel xD
            //let's set up a little MVVM, cos that's what the cool kids are doing:
            var view = new AddInventoryItem(this._nameHistory)
            {
                DataContext = new InventoryViewModel
                {
                    Duration = 1
                }
            };

            //show the dialog
            var result = await DialogHost.Show(view, "RootDialog", view.DialogHost_OnDialogClosing);
            var outp = (InventoryViewModel) view.DataContext;
            if (!(bool) result || !view.AllSet || view.DataContext == null) return;
            outp.DateOfAcquisition = view.MyDate.SelectedDate.Value;

            //outp.ID = _data.Count != 0 ? _data.Max(x => x.ID) + 1 : 0;
            _data.Add(outp);
            if (!this._nameHistory.Contains(outp.Name))
            {
                this._nameHistory.Add(outp.Name);
            }
        }
Пример #2
0
        private async void ButtonBase_OnClick(object sender, RoutedEventArgs e)
        {
            this._nameHistory.Remove(_data[this.InventoryGrid.SelectedIndex].Name);
            //#Model-View-Viewmodel xD
            //let's set up a little MVVM, cos that's what the cool kids are doing:
            var view = new AddInventoryItem(this._nameHistory, ActionwindowType.Edit)
            {
                DataContext = _data[this.InventoryGrid.SelectedIndex]
            };

            //show the dialog
            var result = await DialogHost.Show(view, "RootDialog", view.DialogHost_OnDialogClosing);
            var outp = (InventoryViewModel) view.DataContext;
            if (!(bool) result || !view.AllSet || outp == null) return;

            _data[this.InventoryGrid.SelectedIndex] = outp;
            this._nameHistory.Add(outp.Name);
        }