WPF日积月累之DataGrid样式以及操作数据模板中的控件
标签:none art border NPU openxml layout vat grid obs
一、效果图
二、代码预览
1 "Test.MainWindow"
2 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4 xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6 xmlns:local="clr-namespace:Test"
7 mc:Ignorable="d"
8 Title="MainWindow" Height="450" Width="800">
9 10 "text2ImageConverter"> 11 12 "10">
13 "3 0 3 0" Name="dataGridTestCase" ItemsSource="{Binding CaseCollection}" BorderThickness="0"
14 AutoGenerateColumns="False" CanUserAddRows = "False" SelectedIndex="{Binding SelIndex,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Grid.Row="1" RowHeaderWidth="0">
15 16
31 32 33
47 48
49 50
66 67 68
81 82
83 84 "" MinWidth="8" Width="8" MaxWidth="8">
85 86 87
94 95 96 97
98 "用例描述" MinWidth="373" >
99 100 101
102 103 104 105
106 "结果" Width="40">
107 108 109 "{Binding TestResult, Converter={StaticResource text2ImageConverter},ConverterParameter=0}" Width="20" Height="20">110 111 112 113 "操作" Width="50" >
114 115 116 "Horizontal" HorizontalAlignment="Center">
117
141 142 143 144 145 146
147 148 149
View Code
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
View Code
WPF日积月累之DataGrid样式以及操作数据模板中的控件
标签:none art border NPU openxml layout vat grid obs
原文地址:https://www.cnblogs.com/3xiaolonglong/p/12199746.html
评论