Пример #1
0
        //素材削除クリック
        private void ClickedRemoveMaterialFromListButton(object sender, RoutedEventArgs e)
        {
            var cmd = new MainViewModel.DeleteMaterialDataOfFile();

            //何も選択されずに削除コマンドが実行された場合
            if (MaterialListTable.SelectedIndex == -1)
            {
                MessageBox.Show("削除する素材が選択されていません。", "警告", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }
            var cellInfo = MaterialListTable.SelectedCells[0];
            var content  = cellInfo.Column.GetCellContent(cellInfo.Item);
            MaterialDataGrid SelectedData = (MaterialDataGrid)content.DataContext;

            cmd.ListFromDeletedMaterialName = SelectedData.MaterialName;
            RecevierOfViewModel.CommandViewModelTo(cmd);

            MaterialItemSource.Remove(SelectedData);
            MaterialListTable.ItemsSource = MaterialItemSource;
            return;

            /*
             * ListBoxItem SelectedItem = (ListBoxItem)(MaterialListTable.SelectedItem);
             *
             * cmd.ListFromDeletedMaterialName = (string)(SelectedItem.Content);
             *
             * RecevierOfViewModel.CommandViewModelTo(cmd);
             *
             * MaterialListTable.Items.Remove(SelectedItem);
             *
             * MessageBox.Show("削除が完了しました。", "削除完了", MessageBoxButton.OK, MessageBoxImage.Information);
             */
        }
Пример #2
0
 private void RowMouseDoubleClick(object sender, MouseButtonEventArgs e)
 {
     if (null != MaterialListTable.SelectedItem)
     {
         var ctrl = MaterialListTable.ItemContainerGenerator.ContainerFromItem(MaterialListTable.SelectedItem) as DataGridRow;
         if (null != ctrl)
         {
             if (null != ctrl.InputHitTest(e.GetPosition(ctrl)))
             {
                 //何かしらの行がダブルクリックされた
                 var cellInfo = MaterialListTable.SelectedCells[0];
                 var content  = cellInfo.Column.GetCellContent(cellInfo.Item);
                 MaterialDataGrid SelectedData = (MaterialDataGrid)content.DataContext;
                 //MessageBox.Show(SelectedData.MaterialName);
                 var window = new MaterialEditingDialog(SelectedData.MaterialName);
                 window.Owner = GetWindow(this);
                 window.ShowDialog();
             }
         }
     }
 }