diff --git a/QuickMVVMSetup.sln b/QuickMVVMSetup.sln new file mode 100644 index 0000000..0096bf8 --- /dev/null +++ b/QuickMVVMSetup.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.2.32630.192 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QuickMVVMSetup", "QuickMVVMSetup\QuickMVVMSetup.csproj", "{ABD27BDD-F092-4031-9233-1D09D67B639E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {ABD27BDD-F092-4031-9233-1D09D67B639E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {ABD27BDD-F092-4031-9233-1D09D67B639E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {ABD27BDD-F092-4031-9233-1D09D67B639E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {ABD27BDD-F092-4031-9233-1D09D67B639E}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {53E0FF96-FCE2-449B-9D8F-1892D63E50EF} + EndGlobalSection +EndGlobal diff --git a/QuickMVVMSetup/AddCommand.cs b/QuickMVVMSetup/AddCommand.cs new file mode 100644 index 0000000..505ef43 --- /dev/null +++ b/QuickMVVMSetup/AddCommand.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Input; + +namespace QuickMVVMSetup +{ + public class AddCommand : ICommand + { + public event EventHandler? CanExecuteChanged; + public MainVM assosiatedVM; + + public bool CanExecute(object parameter) + { + return true; + } + + public void Execute(object parameter) + { + assosiatedVM.AddPerson(); + } + + public AddCommand(MainVM vm) + { + assosiatedVM = vm; + } + } +} diff --git a/QuickMVVMSetup/App.xaml b/QuickMVVMSetup/App.xaml new file mode 100644 index 0000000..fda988d --- /dev/null +++ b/QuickMVVMSetup/App.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/QuickMVVMSetup/App.xaml.cs b/QuickMVVMSetup/App.xaml.cs new file mode 100644 index 0000000..3144c13 --- /dev/null +++ b/QuickMVVMSetup/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 QuickMVVMSetup +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + } +} diff --git a/QuickMVVMSetup/AssemblyInfo.cs b/QuickMVVMSetup/AssemblyInfo.cs new file mode 100644 index 0000000..8b5504e --- /dev/null +++ b/QuickMVVMSetup/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/QuickMVVMSetup/ChangeNotifier.cs b/QuickMVVMSetup/ChangeNotifier.cs new file mode 100644 index 0000000..7c51a4f --- /dev/null +++ b/QuickMVVMSetup/ChangeNotifier.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.ComponentModel; +using System.Windows.Input; +using System.Collections.ObjectModel; + +namespace QuickMVVMSetup +{ + public class ChangeNotifier : INotifyPropertyChanged + { + public event PropertyChangedEventHandler? PropertyChanged; + protected void OnPropertyChanged(string propName) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propName)); + } + } +} diff --git a/QuickMVVMSetup/MainVM.cs b/QuickMVVMSetup/MainVM.cs new file mode 100644 index 0000000..2112f06 --- /dev/null +++ b/QuickMVVMSetup/MainVM.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.ComponentModel; +using System.Windows.Input; +using System.Collections.ObjectModel; + +namespace QuickMVVMSetup; + +public class MainVM : ChangeNotifier +{ + + private Person person; + + public Person TargetPerson + { + get { return person; } + set { person = value; OnPropertyChanged(nameof(TargetPerson)); } + } + + private ObservableCollection _persons; //only when added/or removed (not for internal property changes) + + public ObservableCollection Persons + { + get { return _persons; } + set { _persons = value; } + } + + public void AddPerson(object person) + { + Persons.Add(TargetPerson); // Adding to collection + TargetPerson = new Person(); //Resetting it + } + + + //public ICommand CMDAdd { get; set; } + public ICommand CMDAdd => new RelayCommand(AddPerson,null); + + public MainVM() + { + //CMDAdd = new AddCommand(this); + //TargetPerson = new Person(); + Persons = new ObservableCollection(); + } +} diff --git a/QuickMVVMSetup/MainWindow.xaml b/QuickMVVMSetup/MainWindow.xaml new file mode 100644 index 0000000..c0107c0 --- /dev/null +++ b/QuickMVVMSetup/MainWindow.xaml @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + +