diff --git a/PacticeSolution/DataGridEventTriggerSample/App.xaml b/PacticeSolution/DataGridEventTriggerSample/App.xaml
new file mode 100644
index 0000000..d4e9752
--- /dev/null
+++ b/PacticeSolution/DataGridEventTriggerSample/App.xaml
@@ -0,0 +1,9 @@
+
+
+
+
+
diff --git a/PacticeSolution/DataGridEventTriggerSample/App.xaml.cs b/PacticeSolution/DataGridEventTriggerSample/App.xaml.cs
new file mode 100644
index 0000000..20d7cc0
--- /dev/null
+++ b/PacticeSolution/DataGridEventTriggerSample/App.xaml.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Data;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace DataGridEventTriggerSample
+{
+ ///
+ /// Interaction logic for App.xaml
+ ///
+ public partial class App : Application
+ {
+ }
+}
diff --git a/PacticeSolution/DataGridEventTriggerSample/AssemblyInfo.cs b/PacticeSolution/DataGridEventTriggerSample/AssemblyInfo.cs
new file mode 100644
index 0000000..8b5504e
--- /dev/null
+++ b/PacticeSolution/DataGridEventTriggerSample/AssemblyInfo.cs
@@ -0,0 +1,10 @@
+using System.Windows;
+
+[assembly: ThemeInfo(
+ ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
+ //(used if a resource is not found in the page,
+ // or application resource dictionaries)
+ ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
+ //(used if a resource is not found in the page,
+ // app, or any theme specific resource dictionaries)
+)]
diff --git a/PacticeSolution/DataGridEventTriggerSample/DataGridEventTriggerSample.csproj b/PacticeSolution/DataGridEventTriggerSample/DataGridEventTriggerSample.csproj
new file mode 100644
index 0000000..fefb250
--- /dev/null
+++ b/PacticeSolution/DataGridEventTriggerSample/DataGridEventTriggerSample.csproj
@@ -0,0 +1,14 @@
+
+
+
+ WinExe
+ net6.0-windows
+ enable
+ true
+
+
+
+
+
+
+
diff --git a/PacticeSolution/DataGridEventTriggerSample/MainWindow.xaml b/PacticeSolution/DataGridEventTriggerSample/MainWindow.xaml
new file mode 100644
index 0000000..ecff841
--- /dev/null
+++ b/PacticeSolution/DataGridEventTriggerSample/MainWindow.xaml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/PacticeSolution/DataGridEventTriggerSample/MainWindow.xaml.cs b/PacticeSolution/DataGridEventTriggerSample/MainWindow.xaml.cs
new file mode 100644
index 0000000..b365af3
--- /dev/null
+++ b/PacticeSolution/DataGridEventTriggerSample/MainWindow.xaml.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace DataGridEventTriggerSample
+{
+ ///
+ /// Interaction logic for MainWindow.xaml
+ ///
+ public partial class MainWindow : Window
+ {
+ public MainWindow()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/PacticeSolution/DataGridEventTriggerSample/Model/Student.cs b/PacticeSolution/DataGridEventTriggerSample/Model/Student.cs
new file mode 100644
index 0000000..5150c60
--- /dev/null
+++ b/PacticeSolution/DataGridEventTriggerSample/Model/Student.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DataGridEventTriggerSample.Model
+{
+ internal class Student
+ {
+ public string Name { get; set; }
+ public int Age { get; set; }
+ public string Address { get; set; }
+ }
+}
diff --git a/PacticeSolution/DataGridEventTriggerSample/ViewModel/StudentViewModel.cs b/PacticeSolution/DataGridEventTriggerSample/ViewModel/StudentViewModel.cs
new file mode 100644
index 0000000..49d51d3
--- /dev/null
+++ b/PacticeSolution/DataGridEventTriggerSample/ViewModel/StudentViewModel.cs
@@ -0,0 +1,102 @@
+using DataGridEventTriggerSample.Model;
+using Microsoft.Xaml.Behaviors;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Input;
+using System.Windows.Media;
+
+namespace DataGridEventTriggerSample.ViewModel
+{
+ internal class StudentViewModel : Behavior, INotifyPropertyChanged
+ {
+ public static readonly DependencyProperty MouseDownProperty = DependencyProperty.Register(nameof(MouseDownCommand), typeof(ICommand), typeof(StudentViewModel), new PropertyMetadata(null));
+
+ private ObservableCollection _students;
+
+ public event PropertyChangedEventHandler? PropertyChanged;
+
+ public StudentViewModel()
+ {
+ this.Students.Add(new Student { Name = "Agent1", Age = 20, Address = "Location1" });
+ this.Students.Add(new Student { Name = "Agent2", Age = 21, Address = "Location2" });
+ this.Students.Add(new Student { Name = "Agent3", Age = 22, Address = "Location3" });
+ this.Students.Add(new Student { Name = "Agent4", Age = 23, Address = "Location4" });
+ this.Students.Add(new Student { Name = "Agent5", Age = 24, Address = "Location5" });
+ this.Students.Add(new Student { Name = "Agent6", Age = 25, Address = "Location6" });
+ this.Students.Add(new Student { Name = "Agent7", Age = 26, Address = "Location7" });
+ this.Students.Add(new Student { Name = "Agent8", Age = 27, Address = "Location8" });
+ this.Students.Add(new Student { Name = "Agent9", Age = 28, Address = "Location9" });
+ this.Students.Add(new Student { Name = "Agent10", Age = 29, Address = "Location10" });
+ }
+
+ public ObservableCollection Students
+ {
+ get
+ {
+ if (_students == null)
+ _students = new ObservableCollection();
+
+ return _students;
+ }
+ set
+ {
+ _students = value;
+ OnPropertyChanged("Students");
+ }
+ }
+
+
+ public ICommand MouseDownCommand
+ {
+ get { return (ICommand)GetValue(MouseDownProperty); }
+ set { SetValue(MouseDownProperty, value); }
+ }
+
+ protected virtual void OnPropertyChanged(string propertyName)
+ {
+ if (PropertyChanged != null)
+ PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
+ }
+
+ public void OnDataGridMouseDown(object sender, MouseEventArgs e)
+ {
+ DataGrid? dataGrid = sender as DataGrid;
+ if (dataGrid == null)
+ return;
+
+ Student? student = dataGrid.SelectedItem as Student;
+ if (student == null)
+ return;
+
+ for (int i = 0; i < this.Students.Count; i++)
+ {
+ DataGridRow? row = dataGrid.ItemContainerGenerator.ContainerFromIndex(i) as DataGridRow;
+ if (row == null)
+ continue;
+
+ SolidColorBrush brush = new SolidColorBrush(Colors.Transparent);
+ if (this.Students[i].Name.Equals(student.Name))
+ brush = new SolidColorBrush(Colors.LightCoral);
+
+ row.Background = brush;
+ }
+ }
+
+ protected override void OnAttached()
+ {
+ this.AssociatedObject.MouseUp += OnDataGridMouseDown;
+ }
+
+ protected override void OnDetaching()
+ {
+ this.AssociatedObject.MouseUp += OnDataGridMouseDown;
+ }
+ }
+}
diff --git a/PacticeSolution/PacticeSolution.sln b/PacticeSolution/PacticeSolution.sln
index d89a9f3..faea40e 100644
--- a/PacticeSolution/PacticeSolution.sln
+++ b/PacticeSolution/PacticeSolution.sln
@@ -17,11 +17,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ResourceSample", "ResourceS
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MVVMDatabaseSample", "MVVMDatabaseSample\MVVMDatabaseSample.csproj", "{B0A8E6DE-C6A2-488E-A148-9E7812F615F2}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MVVMTextInputDetection", "MVVMTextInputDetection\MVVMTextInputDetection.csproj", "{C55A5081-B142-4120-8F62-3991276EF5C2}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MVVMTextInputDetection", "MVVMTextInputDetection\MVVMTextInputDetection.csproj", "{C55A5081-B142-4120-8F62-3991276EF5C2}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MVVMCanvasRectangle", "MVVMCanvasRectangle\MVVMCanvasRectangle.csproj", "{C7A96511-E6B9-4F80-9C7B-3ABF4FC0AA4B}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MVVMCanvasRectangle", "MVVMCanvasRectangle\MVVMCanvasRectangle.csproj", "{C7A96511-E6B9-4F80-9C7B-3ABF4FC0AA4B}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MVVMButtonControl", "MVVMButtonControl\MVVMButtonControl.csproj", "{8FE48C46-5529-4D0D-A96E-01A5A79B0B18}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MVVMButtonControl", "MVVMButtonControl\MVVMButtonControl.csproj", "{8FE48C46-5529-4D0D-A96E-01A5A79B0B18}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataGridEventTriggerSample", "DataGridEventTriggerSample\DataGridEventTriggerSample.csproj", "{48CCBA2F-A583-4DAF-9F64-B9642CDB49FF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -69,6 +71,10 @@ Global
{8FE48C46-5529-4D0D-A96E-01A5A79B0B18}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8FE48C46-5529-4D0D-A96E-01A5A79B0B18}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8FE48C46-5529-4D0D-A96E-01A5A79B0B18}.Release|Any CPU.Build.0 = Release|Any CPU
+ {48CCBA2F-A583-4DAF-9F64-B9642CDB49FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {48CCBA2F-A583-4DAF-9F64-B9642CDB49FF}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {48CCBA2F-A583-4DAF-9F64-B9642CDB49FF}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {48CCBA2F-A583-4DAF-9F64-B9642CDB49FF}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE