diff --git a/PacticeSolution/CommandSample/App.xaml b/PacticeSolution/CommandSample/App.xaml
new file mode 100644
index 0000000..bbc6767
--- /dev/null
+++ b/PacticeSolution/CommandSample/App.xaml
@@ -0,0 +1,9 @@
+
+
+
+
+
diff --git a/PacticeSolution/CommandSample/App.xaml.cs b/PacticeSolution/CommandSample/App.xaml.cs
new file mode 100644
index 0000000..dbf1fec
--- /dev/null
+++ b/PacticeSolution/CommandSample/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 CommandSample
+{
+ ///
+ /// Interaction logic for App.xaml
+ ///
+ public partial class App : Application
+ {
+ }
+}
diff --git a/PacticeSolution/CommandSample/AssemblyInfo.cs b/PacticeSolution/CommandSample/AssemblyInfo.cs
new file mode 100644
index 0000000..8b5504e
--- /dev/null
+++ b/PacticeSolution/CommandSample/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/CommandSample/CommandSample.csproj b/PacticeSolution/CommandSample/CommandSample.csproj
new file mode 100644
index 0000000..4106cb0
--- /dev/null
+++ b/PacticeSolution/CommandSample/CommandSample.csproj
@@ -0,0 +1,10 @@
+
+
+
+ WinExe
+ net6.0-windows
+ enable
+ true
+
+
+
diff --git a/PacticeSolution/CommandSample/Commands/MessageCommand.cs b/PacticeSolution/CommandSample/Commands/MessageCommand.cs
new file mode 100644
index 0000000..0f67457
--- /dev/null
+++ b/PacticeSolution/CommandSample/Commands/MessageCommand.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Input;
+
+namespace CommandSample.Commands
+{
+ internal class MessageCommand : ICommand
+ {
+ private Action _execute;
+ private Predicate _canExecute;
+
+ public event EventHandler? CanExecuteChanged
+ {
+ add { CommandManager.RequerySuggested += value; }
+ remove { CommandManager.RequerySuggested -= value; }
+ }
+
+ public MessageCommand(Action execute, Predicate canExecute)
+ {
+ _execute = execute;
+ _canExecute = canExecute;
+ }
+
+ public bool CanExecute(object? parameter)
+ {
+ bool result = _canExecute.Invoke(parameter as string);
+ return result;
+ }
+
+ public void Execute(object? parameter)
+ {
+ if (_execute == null)
+ return;
+
+ _execute.Invoke(parameter as string);
+ }
+ }
+}
diff --git a/PacticeSolution/CommandSample/MainWindow.xaml b/PacticeSolution/CommandSample/MainWindow.xaml
new file mode 100644
index 0000000..27a4d62
--- /dev/null
+++ b/PacticeSolution/CommandSample/MainWindow.xaml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/PacticeSolution/CommandSample/MainWindow.xaml.cs b/PacticeSolution/CommandSample/MainWindow.xaml.cs
new file mode 100644
index 0000000..cac7533
--- /dev/null
+++ b/PacticeSolution/CommandSample/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 CommandSample
+{
+ ///
+ /// Interaction logic for MainWindow.xaml
+ ///
+ public partial class MainWindow : Window
+ {
+ public MainWindow()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/PacticeSolution/CommandSample/ViewModels/MessageViewModel.cs b/PacticeSolution/CommandSample/ViewModels/MessageViewModel.cs
new file mode 100644
index 0000000..b8120fe
--- /dev/null
+++ b/PacticeSolution/CommandSample/ViewModels/MessageViewModel.cs
@@ -0,0 +1,33 @@
+using CommandSample.Commands;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace CommandSample.ViewModels
+{
+ internal class MessageViewModel
+ {
+ public MessageCommand DisplayMessageCommand { get; set; }
+
+ public MessageViewModel()
+ {
+ this.DisplayMessageCommand = new MessageCommand(DisplayMessage, AddMessage);
+ }
+
+ public void DisplayMessage(string param)
+ {
+ MessageBox.Show($"Clicked! (Param: {param})");
+ }
+
+ public bool AddMessage(string param)
+ {
+ if (string.IsNullOrEmpty(param))
+ return false;
+
+ return true;
+ }
+ }
+}
diff --git a/PacticeSolution/PacticeSolution.sln b/PacticeSolution/PacticeSolution.sln
index 5b21d82..93d6085 100644
--- a/PacticeSolution/PacticeSolution.sln
+++ b/PacticeSolution/PacticeSolution.sln
@@ -119,6 +119,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ObervableCollectionSample",
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataTemplateSample", "DataTemplateSample\DataTemplateSample.csproj", "{D6507C41-143B-45D2-9A45-F822A9E22B7E}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommandSample", "CommandSample\CommandSample.csproj", "{AFB4006F-917A-4358-898F-8C4DC0A1E6C8}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -357,6 +359,10 @@ Global
{D6507C41-143B-45D2-9A45-F822A9E22B7E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D6507C41-143B-45D2-9A45-F822A9E22B7E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D6507C41-143B-45D2-9A45-F822A9E22B7E}.Release|Any CPU.Build.0 = Release|Any CPU
+ {AFB4006F-917A-4358-898F-8C4DC0A1E6C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {AFB4006F-917A-4358-898F-8C4DC0A1E6C8}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {AFB4006F-917A-4358-898F-8C4DC0A1E6C8}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {AFB4006F-917A-4358-898F-8C4DC0A1E6C8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE