WPF日积月累之DataGrid样式以及操作数据模板中的控件
阅读原文时间:2023年07月10日阅读:2

一、效果图

二、代码预览

1 9 10 11 12 13 15 16 31 32 33 47 48 49 50 66 67 ¨C22C 82 83 84 85 ¨C23C 96 97 98 99 ¨C24C 104 105 106 107 ¨C25C 112 113 114 ¨C26C 144 145 146 147 148 149

1 using System;
2 using System.Collections.Generic;
3 using System.Collections.ObjectModel;
4 using System.ComponentModel;
5 using System.Globalization;
6 using System.Linq;
7 using System.Text;
8 using System.Windows;
9 using System.Windows.Controls;
10 using System.Windows.Data;
11 using System.Windows.Documents;
12 using System.Windows.Input;
13 using System.Windows.Media;
14 using System.Windows.Media.Imaging;
15 using System.Windows.Navigation;
16 using System.Windows.Shapes;
17
18 namespace Test
19 {
20
21 ///

22 /// MainWindow.xaml 的交互逻辑 23 ///
24 public partial class MainWindow : Window, INotifyPropertyChanged
25 {
26 #region INotifyPropertyChanged interface
27 public event PropertyChangedEventHandler PropertyChanged;
28 public virtual void OnPropertyChanged(string propertyName)
29 {
30 PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
31 }
32 #endregion
33 public ObservableCollection CaseCollection { get; set; }
34 private int preSelIndex = 0;
35 private int selIndex = -1;
36 public int SelIndex
37 {
38 get
39 {
40 return selIndex;
41 }
42 set
43 {
44 if(value != selIndex)
45 {
46 selIndex = value;
47
48 DataGridRow preRow = GetRow(dataGridTestCase, preSelIndex);
49 Label preLb = FindVisualChildByName