Ejemplo n.º 1
0
        private void LoadParts()
        {
            if (!_rdeMode && Owner != null)
            {
                detailGrid.IsEnabled = false;

                var service = new MaterialService(User);
                var list    = service.GetMaterialParts(Owner.ObjectID.Value);

                _model = new ObservableCollection <ViewModelBase>(list.ConvertAll((part) => {
                    var viewmodel          = new MaterialPartViewModel(part);
                    viewmodel.DataChanged += new DataChangedHandler(viewmodel_DataChanged);
                    return(viewmodel);
                }));

                lst.ItemsSource = _model;

                if (_model.Count > 0)
                {
                    lst.SelectedItem = _model[0];
                }
            }

            _populated = true;
        }
Ejemplo n.º 2
0
        private void AddNew()
        {
            var part = new MaterialPart();

            part.MaterialID     = Owner.ObjectID.Value;
            part.MaterialPartID = -1;
            part.PartName       = "";

            var viewModel = new MaterialPartViewModel(part);

            _model.Add(viewModel);
            lst.SelectedItem = viewModel;

            RegisterPendingChange(new InsertMaterialPartCommand(part, Owner));
        }