コード例 #1
0
        /// <summary>
        /// 插入一条路面类型信息,点击该按钮,会弹窗pavement,填写完整则添加一条路面类型信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Insert(object sender, RoutedEventArgs e)
        {
            //获取增加数据时Index索引
            PavementTypeWindow pavementTypeWindow = new PavementTypeWindow(testRouteViewModelSelf, null);

            pavementTypeWindow.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            pavementTypeWindow.ShowDialog();
            if (pavementTypeWindow.ptSelf.Name != null)
            {
                this.ptInfo.Add(pavementTypeWindow.ptSelf);//获取子窗口pt路面类型信息
            }

            this.pavementTypeInfoDataGrid.ItemsSource = null;
            this.pavementTypeInfoDataGrid.ItemsSource = this.ptInfo;
        }
コード例 #2
0
        /// <summary>
        /// 编辑按钮 点击DataGrid中的编辑按钮,对路面类型信息进行编辑,记录选中的索引,等待路面类型修改窗
        /// 口关闭后,对对应的索引值直接赋值
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <param name="ptInfo">存储路面类型信息</param>
        private void EditClick(object sender, RoutedEventArgs e)
        {
            PavementType pt  = this.pavementTypeInfoDataGrid.SelectedItem as PavementType;
            int          idx = -1;//记录路面类型在私有变量中的位置

            for (int i = 0; i < ptInfo.Count(); i++)
            {
                if (ptInfo[i] == pt)
                {
                    idx = i;
                }
            }

            //打开修改路面类型窗口
            PavementTypeWindow pavementTypeWindow = new PavementTypeWindow(testRouteViewModelSelf, pt);

            pavementTypeWindow.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            pavementTypeWindow.ShowDialog();

            //当修改当前路面类型时,将修改过的路面类型进行赋值
            if (idx != -1)
            {
                //trSelf.PavementTypeInfo[idx] = pavementTypeWindow.ptSelf;
                ptInfo[idx] = pavementTypeWindow.ptSelf;
            }

            //  if (OperationFlag == "Update")
            //  {
            //更新当前视图
            this.pavementTypeInfoDataGrid.ItemsSource = null;
            this.pavementTypeInfoDataGrid.ItemsSource = ptInfo;
            // ptList = tr.PavementTypeInfo;
            // }
            // else
            // {
            //     //更新当前视图
            //     this.pavementTypeInfoDataGrid.ItemsSource = null;
            //     this.pavementTypeInfoDataGrid.ItemsSource = trSelf.PavementTypeInfo;
            //     ptInfo = trSelf.PavementTypeInfo;
            // }
            //var MyVM = this.testRouteViewModelSelf;
            //if (MyVM != null && MyVM.UpdatePavementTypeCommand.CanExecute(ptList))
            //    MyVM.UpdatePavementTypeCommand.Execute(ptList);
        }