Exemplo n.º 1
0
        private void MenuItem_Add(object sender, RoutedEventArgs e)
        {
            // получить Id выьранного элемента, запустить форму с этим парамметром
            if (_selectProduct == null)
            {
                return;
            }
            var cvm  = new ComponentViewModel(_selectProduct, true);
            var form = new ComponentForm(_selectProduct, true)
            {
                DataContext = cvm,
                Owner       = this
            };
            var result = form.ShowDialog();

            if (!result.HasValue)
            {
                return;
            }
            if (!result.Value)
            {
                return;
            }

            _selectProduct.ProductCollection.Add(cvm.Product);
            CollectionViewSource.GetDefaultView(ProductsTreeView.ItemsSource).Refresh();
        }
Exemplo n.º 2
0
        private void MenuItem_AddRoot(object sender, RoutedEventArgs e)
        {
            var cvm  = new ComponentViewModel();
            var form = new ComponentForm
            {
                DataContext = cvm,
                Owner       = this
            };
            var result = form.ShowDialog();

            if (!result.HasValue)
            {
                return;
            }
            if (!result.Value)
            {
                return;
            }

            if (cvm.Product == null)
            {
                return;
            }
            _viewModel.Products.Add(cvm.Product);
            CollectionViewSource.GetDefaultView(ProductsTreeView.ItemsSource).Refresh();
        }
Exemplo n.º 3
0
        private void MenuItem_Rename(object sender, RoutedEventArgs e)
        {
            if (_selectProduct == null)
            {
                return;
            }
            var form = new ComponentForm(_selectProduct, false, true)
            {
                DataContext = new ComponentViewModel(_selectProduct, false, true),
                Owner       = this
            };
            var result = form.ShowDialog();

            if (!result.HasValue)
            {
                return;
            }
            if (!result.Value)
            {
                return;
            }

            CollectionViewSource.GetDefaultView(ProductsTreeView.ItemsSource).Refresh();
        }