├── .gitattributes
├── .gitignore
├── README.md
├── WinFormMVVM.sln
├── WinFormMVVM
├── App.config
├── HomeView.Designer.cs
├── HomeView.cs
├── HomeView.resx
├── Program.cs
├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
├── ViewModels
│ └── HomeViewModel.cs
├── WinFormMVVM.csproj
└── packages.config
└── packages
├── Rx-Core.2.2.5
├── Rx-Core.2.2.5.nupkg
└── lib
│ ├── net40
│ ├── System.Reactive.Core.XML
│ └── System.Reactive.Core.dll
│ ├── net45
│ ├── System.Reactive.Core.XML
│ └── System.Reactive.Core.dll
│ ├── portable-net40+sl5+win8+wp8
│ ├── System.Reactive.Core.XML
│ └── System.Reactive.Core.dll
│ ├── portable-net45+winrt45+wp8+wpa81
│ ├── System.Reactive.Core.XML
│ └── System.Reactive.Core.dll
│ ├── portable-win81+wpa81
│ ├── System.Reactive.Core.XML
│ └── System.Reactive.Core.dll
│ ├── portable-windows8+net45+wp8
│ ├── System.Reactive.Core.XML
│ └── System.Reactive.Core.dll
│ ├── sl5
│ ├── System.Reactive.Core.XML
│ └── System.Reactive.Core.dll
│ ├── windows8
│ ├── System.Reactive.Core.XML
│ └── System.Reactive.Core.dll
│ ├── windowsphone71
│ ├── System.Reactive.Core.XML
│ └── System.Reactive.Core.dll
│ └── windowsphone8
│ ├── System.Reactive.Core.XML
│ └── System.Reactive.Core.dll
├── Rx-Interfaces.2.2.5
├── Rx-Interfaces.2.2.5.nupkg
└── lib
│ ├── net40
│ ├── System.Reactive.Interfaces.XML
│ └── System.Reactive.Interfaces.dll
│ ├── net45
│ ├── System.Reactive.Interfaces.XML
│ └── System.Reactive.Interfaces.dll
│ ├── portable-net40+sl5+win8+wp8
│ ├── System.Reactive.Interfaces.XML
│ └── System.Reactive.Interfaces.dll
│ ├── portable-net45+winrt45+wp8+wpa81
│ ├── System.Reactive.Interfaces.XML
│ └── System.Reactive.Interfaces.dll
│ ├── portable-win81+wpa81
│ ├── System.Reactive.Interfaces.XML
│ └── System.Reactive.Interfaces.dll
│ ├── portable-windows8+net45+wp8
│ ├── System.Reactive.Interfaces.XML
│ └── System.Reactive.Interfaces.dll
│ ├── sl5
│ ├── System.Reactive.Interfaces.XML
│ └── System.Reactive.Interfaces.dll
│ ├── windows8
│ ├── System.Reactive.Interfaces.XML
│ └── System.Reactive.Interfaces.dll
│ ├── windowsphone71
│ ├── System.Reactive.Interfaces.XML
│ └── System.Reactive.Interfaces.dll
│ └── windowsphone8
│ ├── System.Reactive.Interfaces.XML
│ └── System.Reactive.Interfaces.dll
├── Rx-Linq.2.2.5
├── Rx-Linq.2.2.5.nupkg
└── lib
│ ├── net40
│ ├── System.Reactive.Linq.XML
│ └── System.Reactive.Linq.dll
│ ├── net45
│ ├── System.Reactive.Linq.XML
│ └── System.Reactive.Linq.dll
│ ├── portable-net40+sl5+win8+wp8
│ ├── System.Reactive.Linq.XML
│ └── System.Reactive.Linq.dll
│ ├── portable-net45+winrt45+wp8+wpa81
│ ├── System.Reactive.Linq.XML
│ └── System.Reactive.Linq.dll
│ ├── portable-win81+wpa81
│ ├── System.Reactive.Linq.XML
│ └── System.Reactive.Linq.dll
│ ├── portable-windows8+net45+wp8
│ ├── System.Reactive.Linq.XML
│ └── System.Reactive.Linq.dll
│ ├── sl5
│ ├── System.Reactive.Linq.XML
│ └── System.Reactive.Linq.dll
│ ├── windows8
│ ├── System.Reactive.Linq.XML
│ └── System.Reactive.Linq.dll
│ ├── windowsphone71
│ ├── System.Reactive.Linq.XML
│ └── System.Reactive.Linq.dll
│ └── windowsphone8
│ ├── System.Reactive.Linq.XML
│ └── System.Reactive.Linq.dll
├── Rx-Main.2.2.5
└── Rx-Main.2.2.5.nupkg
├── Rx-PlatformServices.2.2.5
├── Rx-PlatformServices.2.2.5.nupkg
└── lib
│ ├── net40
│ ├── System.Reactive.PlatformServices.XML
│ └── System.Reactive.PlatformServices.dll
│ ├── net45
│ ├── System.Reactive.PlatformServices.XML
│ └── System.Reactive.PlatformServices.dll
│ ├── portable-net40+sl5+win8+wp8
│ ├── System.Reactive.PlatformServices.XML
│ └── System.Reactive.PlatformServices.dll
│ ├── portable-net45+winrt45+wp8+wpa81
│ ├── System.Reactive.PlatformServices.XML
│ └── System.Reactive.PlatformServices.dll
│ ├── portable-win81+wpa81
│ ├── System.Reactive.PlatformServices.XML
│ └── System.Reactive.PlatformServices.dll
│ ├── portable-windows8+net45+wp8
│ ├── System.Reactive.PlatformServices.XML
│ └── System.Reactive.PlatformServices.dll
│ ├── sl5
│ ├── System.Reactive.PlatformServices.XML
│ └── System.Reactive.PlatformServices.dll
│ ├── windows8
│ ├── System.Reactive.PlatformServices.XML
│ └── System.Reactive.PlatformServices.dll
│ ├── windowsphone71
│ ├── System.Reactive.PlatformServices.XML
│ └── System.Reactive.PlatformServices.dll
│ └── windowsphone8
│ ├── System.Reactive.PlatformServices.XML
│ └── System.Reactive.PlatformServices.dll
├── Rx-Xaml.2.2.5
├── Rx-Xaml.2.2.5.nupkg
└── lib
│ ├── net40
│ ├── System.Reactive.Windows.Threading.XML
│ └── System.Reactive.Windows.Threading.dll
│ ├── net45
│ ├── System.Reactive.Windows.Threading.XML
│ └── System.Reactive.Windows.Threading.dll
│ ├── portable-win81+wpa81
│ ├── System.Reactive.Windows.Threading.XML
│ └── System.Reactive.Windows.Threading.dll
│ ├── sl5
│ ├── System.Reactive.Windows.Threading.XML
│ └── System.Reactive.Windows.Threading.dll
│ ├── windows8
│ ├── System.Reactive.Windows.Threading.XML
│ └── System.Reactive.Windows.Threading.dll
│ ├── windowsphone71
│ ├── System.Reactive.Windows.Threading.XML
│ └── System.Reactive.Windows.Threading.dll
│ └── windowsphone8
│ ├── System.Reactive.Windows.Threading.XML
│ └── System.Reactive.Windows.Threading.dll
├── Splat.1.5.1
├── Splat.1.5.1.nupkg
└── lib
│ ├── MonoMac
│ ├── Splat.dll
│ └── Splat.dll.mdb
│ ├── Net45
│ └── Splat.dll
│ ├── NetCore45
│ ├── Splat.dll
│ └── Splat.pri
│ ├── Portable-Win81+Wpa81
│ ├── Splat.dll
│ └── Splat.pri
│ ├── Portable-net45+win+wpa81+wp80
│ └── Splat.dll
│ ├── Xamarin.Mac10
│ ├── Splat-XamarinMac.csproj.FilesWrittenAbsolute.txt
│ ├── Splat.dll
│ └── Splat.dll.mdb
│ ├── Xamarin.iOS10
│ ├── Splat.dll
│ └── Splat.dll.mdb
│ ├── monoandroid
│ ├── Splat.dll
│ └── Splat.dll.mdb
│ ├── monotouch
│ ├── Splat.dll
│ └── Splat.dll.mdb
│ └── wp8
│ └── Splat.dll
├── reactiveui-core.6.2.1.1
├── lib
│ ├── MonoAndroid
│ │ ├── ReactiveUI.dll
│ │ ├── ReactiveUI.dll.mdb
│ │ └── ReactiveUI.xml
│ ├── MonoMac
│ │ ├── ReactiveUI.dll
│ │ ├── ReactiveUI.dll.mdb
│ │ └── ReactiveUI.xml
│ ├── Monotouch
│ │ ├── ReactiveUI.dll
│ │ ├── ReactiveUI.dll.mdb
│ │ └── ReactiveUI.xml
│ ├── Net45
│ │ ├── ReactiveUI.dll
│ │ └── ReactiveUI.xml
│ ├── Portable-Net45+Win8+WP8+WPA81
│ │ ├── ReactiveUI.XML
│ │ └── ReactiveUI.dll
│ ├── Portable-Win81+WPA81
│ │ ├── ReactiveUI.dll
│ │ ├── ReactiveUI.pri
│ │ ├── ReactiveUI.xml
│ │ └── ReactiveUI
│ │ │ ├── ReactiveUI.xr.xml
│ │ │ └── Themes
│ │ │ └── generic-winrt.xbf
│ ├── WP8
│ │ ├── ReactiveUI.dll
│ │ └── ReactiveUI.xml
│ ├── Win8
│ │ ├── ReactiveUI.dll
│ │ ├── ReactiveUI.pri
│ │ ├── ReactiveUI.xml
│ │ └── ReactiveUI
│ │ │ └── Themes
│ │ │ └── generic-winrt.xaml
│ └── Xamarin.iOS10
│ │ ├── ReactiveUI.dll
│ │ ├── ReactiveUI.dll.mdb
│ │ └── ReactiveUI.xml
└── reactiveui-core.6.2.1.1.nupkg
├── reactiveui-winforms.6.2.1.1
├── lib
│ └── net45
│ │ ├── ReactiveUI.Winforms.dll
│ │ └── ReactiveUI.Winforms.xml
└── reactiveui-winforms.6.2.1.1.nupkg
└── repositories.config
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.sln.docstates
8 |
9 | # Build results
10 |
11 | [Dd]ebug/
12 | [Rr]elease/
13 | x64/
14 | build/
15 | [Bb]in/
16 | [Oo]bj/
17 |
18 | # Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets
19 | !packages/*/build/
20 |
21 | # MSTest test Results
22 | [Tt]est[Rr]esult*/
23 | [Bb]uild[Ll]og.*
24 |
25 | *_i.c
26 | *_p.c
27 | *.ilk
28 | *.meta
29 | *.obj
30 | *.pch
31 | *.pdb
32 | *.pgc
33 | *.pgd
34 | *.rsp
35 | *.sbr
36 | *.tlb
37 | *.tli
38 | *.tlh
39 | *.tmp
40 | *.tmp_proj
41 | *.log
42 | *.vspscc
43 | *.vssscc
44 | .builds
45 | *.pidb
46 | *.log
47 | *.scc
48 |
49 | # Visual C++ cache files
50 | ipch/
51 | *.aps
52 | *.ncb
53 | *.opensdf
54 | *.sdf
55 | *.cachefile
56 |
57 | # Visual Studio profiler
58 | *.psess
59 | *.vsp
60 | *.vspx
61 |
62 | # Guidance Automation Toolkit
63 | *.gpState
64 |
65 | # ReSharper is a .NET coding add-in
66 | _ReSharper*/
67 | *.[Rr]e[Ss]harper
68 |
69 | # TeamCity is a build add-in
70 | _TeamCity*
71 |
72 | # DotCover is a Code Coverage Tool
73 | *.dotCover
74 |
75 | # NCrunch
76 | *.ncrunch*
77 | .*crunch*.local.xml
78 |
79 | # Installshield output folder
80 | [Ee]xpress/
81 |
82 | # DocProject is a documentation generator add-in
83 | DocProject/buildhelp/
84 | DocProject/Help/*.HxT
85 | DocProject/Help/*.HxC
86 | DocProject/Help/*.hhc
87 | DocProject/Help/*.hhk
88 | DocProject/Help/*.hhp
89 | DocProject/Help/Html2
90 | DocProject/Help/html
91 |
92 | # Click-Once directory
93 | publish/
94 |
95 | # Publish Web Output
96 | *.Publish.xml
97 |
98 | # NuGet Packages Directory
99 | ## TODO: If you have NuGet Package Restore enabled, uncomment the next line
100 | #packages/
101 |
102 | # Windows Azure Build Output
103 | csx
104 | *.build.csdef
105 |
106 | # Windows Store app package directory
107 | AppPackages/
108 |
109 | # Others
110 | sql/
111 | *.Cache
112 | ClientBin/
113 | [Ss]tyle[Cc]op.*
114 | ~$*
115 | *~
116 | *.dbmdl
117 | *.[Pp]ublish.xml
118 | *.pfx
119 | *.publishsettings
120 |
121 | # RIA/Silverlight projects
122 | Generated_Code/
123 |
124 | # Backup & report files from converting an old project file to a newer
125 | # Visual Studio version. Backup files are not needed, because we have git ;-)
126 | _UpgradeReport_Files/
127 | Backup*/
128 | UpgradeLog*.XML
129 | UpgradeLog*.htm
130 |
131 | # SQL Server files
132 | App_Data/*.mdf
133 | App_Data/*.ldf
134 |
135 |
136 | #LightSwitch generated files
137 | GeneratedArtifacts/
138 | _Pvt_Extensions/
139 | ModelManifest.xml
140 |
141 | # =========================
142 | # Windows detritus
143 | # =========================
144 |
145 | # Windows image file caches
146 | Thumbs.db
147 | ehthumbs.db
148 |
149 | # Folder config file
150 | Desktop.ini
151 |
152 | # Recycle Bin used on file shares
153 | $RECYCLE.BIN/
154 |
155 | # Mac desktop service store files
156 | .DS_Store
157 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | WinFormMVVM
2 | ===========
3 |
4 | Implementation of Using ReactiveUI for WinForms MVVM Design. (http://www.codeproject.com/Articles/801986/Using-ReactiveUI-for-WinForms-MVVM-Design)
5 | Developed using VS2013 c#
6 |
7 | Original article written by http://www.codeproject.com/Members/User-10914367
8 |
9 | Thanks for a great simple ReactiveUI sample!
10 |
--------------------------------------------------------------------------------
/WinFormMVVM.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2013
4 | VisualStudioVersion = 12.0.30723.0
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinFormMVVM", "WinFormMVVM\WinFormMVVM.csproj", "{EF792E65-F952-4B36-B3F2-75348C0819BD}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {EF792E65-F952-4B36-B3F2-75348C0819BD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {EF792E65-F952-4B36-B3F2-75348C0819BD}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {EF792E65-F952-4B36-B3F2-75348C0819BD}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {EF792E65-F952-4B36-B3F2-75348C0819BD}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | EndGlobal
23 |
--------------------------------------------------------------------------------
/WinFormMVVM/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/WinFormMVVM/HomeView.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace WinFormMVVM
2 | {
3 | partial class HomeView
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Windows Form Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.btnOK = new System.Windows.Forms.Button();
32 | this.textBoxMyInput = new System.Windows.Forms.TextBox();
33 | this.label1 = new System.Windows.Forms.Label();
34 | this.toolStripMyStatus = new System.Windows.Forms.StatusStrip();
35 | this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel();
36 | this.toolStripMyStatus.SuspendLayout();
37 | this.SuspendLayout();
38 | //
39 | // btnOK
40 | //
41 | this.btnOK.Location = new System.Drawing.Point(321, 97);
42 | this.btnOK.Name = "btnOK";
43 | this.btnOK.Size = new System.Drawing.Size(75, 23);
44 | this.btnOK.TabIndex = 0;
45 | this.btnOK.Text = "OK";
46 | this.btnOK.UseVisualStyleBackColor = true;
47 | //
48 | // textBoxMyInput
49 | //
50 | this.textBoxMyInput.Location = new System.Drawing.Point(171, 99);
51 | this.textBoxMyInput.Name = "textBoxMyInput";
52 | this.textBoxMyInput.Size = new System.Drawing.Size(100, 20);
53 | this.textBoxMyInput.TabIndex = 1;
54 | //
55 | // label1
56 | //
57 | this.label1.AutoSize = true;
58 | this.label1.Location = new System.Drawing.Point(82, 102);
59 | this.label1.Name = "label1";
60 | this.label1.Size = new System.Drawing.Size(83, 13);
61 | this.label1.TabIndex = 2;
62 | this.label1.Text = "Enter some text:";
63 | //
64 | // toolStripMyStatus
65 | //
66 | this.toolStripMyStatus.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
67 | this.toolStripStatusLabel1});
68 | this.toolStripMyStatus.Location = new System.Drawing.Point(0, 390);
69 | this.toolStripMyStatus.Name = "toolStripMyStatus";
70 | this.toolStripMyStatus.Size = new System.Drawing.Size(654, 22);
71 | this.toolStripMyStatus.TabIndex = 3;
72 | this.toolStripMyStatus.Text = "Default";
73 | //
74 | // toolStripStatusLabel1
75 | //
76 | this.toolStripStatusLabel1.Name = "toolStripStatusLabel1";
77 | this.toolStripStatusLabel1.Size = new System.Drawing.Size(45, 17);
78 | this.toolStripStatusLabel1.Text = "Default";
79 | //
80 | // HomeView
81 | //
82 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
83 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
84 | this.ClientSize = new System.Drawing.Size(654, 412);
85 | this.Controls.Add(this.toolStripMyStatus);
86 | this.Controls.Add(this.label1);
87 | this.Controls.Add(this.textBoxMyInput);
88 | this.Controls.Add(this.btnOK);
89 | this.Name = "HomeView";
90 | this.Text = "HomeView";
91 | this.toolStripMyStatus.ResumeLayout(false);
92 | this.toolStripMyStatus.PerformLayout();
93 | this.ResumeLayout(false);
94 | this.PerformLayout();
95 |
96 | }
97 |
98 | #endregion
99 |
100 | private System.Windows.Forms.Button btnOK;
101 | private System.Windows.Forms.TextBox textBoxMyInput;
102 | private System.Windows.Forms.Label label1;
103 | private System.Windows.Forms.StatusStrip toolStripMyStatus;
104 | private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1;
105 | }
106 | }
--------------------------------------------------------------------------------
/WinFormMVVM/HomeView.cs:
--------------------------------------------------------------------------------
1 | using System.Windows.Forms;
2 | using ReactiveUI;
3 | using WinFormMVVM.ViewModels;
4 |
5 | namespace WinFormMVVM
6 | {
7 | public partial class HomeView : Form, IViewFor
8 | {
9 | public HomeView()
10 | {
11 | InitializeComponent();
12 | VM = new HomeViewModel();
13 |
14 | // Bind the view to the ReactiveUI viewmodel
15 | this.Bind(VM, x => x.EnteredText, x => x.textBoxMyInput.Text);
16 | this.Bind(VM, x => x.Status, x => x.toolStripStatusLabel1.Text);
17 | this.BindCommand(VM, x => x.OKCmd, x => x.btnOK);
18 | }
19 | public HomeViewModel VM { get; set; }
20 |
21 | object IViewFor.ViewModel
22 | {
23 | get { return VM; }
24 | set { VM = (HomeViewModel)value; }
25 | }
26 |
27 | HomeViewModel IViewFor.ViewModel
28 | {
29 | get { return VM; }
30 | set { VM = value; }
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/WinFormMVVM/HomeView.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 | 17, 17
122 |
123 |
--------------------------------------------------------------------------------
/WinFormMVVM/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using System.Windows.Forms;
6 | using WinFormMVVM.ViewModels;
7 |
8 | namespace WinFormMVVM
9 | {
10 | static class Program
11 | {
12 | ///
13 | /// The main entry point for the application.
14 | ///
15 | [STAThread]
16 | static void Main()
17 | {
18 | Application.EnableVisualStyles();
19 | Application.SetCompatibleTextRenderingDefault(false);
20 | Application.Run(new HomeView());
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/WinFormMVVM/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("WinFormMVVM")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("WinFormMVVM")]
13 | [assembly: AssemblyCopyright("Copyright © 2014")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("a1827b4b-f07c-4bef-834e-2c9b8adf94e4")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/WinFormMVVM/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.34014
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace WinFormMVVM.Properties
12 | {
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources
26 | {
27 |
28 | private static global::System.Resources.ResourceManager resourceMan;
29 |
30 | private static global::System.Globalization.CultureInfo resourceCulture;
31 |
32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
33 | internal Resources()
34 | {
35 | }
36 |
37 | ///
38 | /// Returns the cached ResourceManager instance used by this class.
39 | ///
40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
41 | internal static global::System.Resources.ResourceManager ResourceManager
42 | {
43 | get
44 | {
45 | if ((resourceMan == null))
46 | {
47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WinFormMVVM.Properties.Resources", typeof(Resources).Assembly);
48 | resourceMan = temp;
49 | }
50 | return resourceMan;
51 | }
52 | }
53 |
54 | ///
55 | /// Overrides the current thread's CurrentUICulture property for all
56 | /// resource lookups using this strongly typed resource class.
57 | ///
58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
59 | internal static global::System.Globalization.CultureInfo Culture
60 | {
61 | get
62 | {
63 | return resourceCulture;
64 | }
65 | set
66 | {
67 | resourceCulture = value;
68 | }
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/WinFormMVVM/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 | text/microsoft-resx
107 |
108 |
109 | 2.0
110 |
111 |
112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
113 |
114 |
115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
--------------------------------------------------------------------------------
/WinFormMVVM/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.34014
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace WinFormMVVM.Properties
12 | {
13 |
14 |
15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
18 | {
19 |
20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
21 |
22 | public static Settings Default
23 | {
24 | get
25 | {
26 | return defaultInstance;
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/WinFormMVVM/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/WinFormMVVM/ViewModels/HomeViewModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using ReactiveUI;
3 |
4 | namespace WinFormMVVM.ViewModels
5 | {
6 | ///
7 | ///
8 | /// ViewModel that will process data and events
9 | /// The ViewModel inherits from the ReactiveObject class.
10 | /// This class grants your classes access to the RaiseAndSetIfChanged helper function.
11 | /// This conveniently wires up your properties to the INotifyPropertyChanged/IObservable
12 | /// interfaces, so in one step you have a class that can be data bound AND observed using
13 | /// Reactive Extensions.
14 | ///
15 | /// In the constructor for the ViewModel we set up the conditions under which something
16 | /// happens, i.e. when the OK button is clicked. An IObservable object is returned from
17 | /// the WhenAny extension, which allows you to observe whenever one or more properties
18 | /// on an object have changed. We then Subscribe to the events of the ReactiveCommand,
19 | /// which will update the status message. Note that the ViewModel has no references to
20 | /// any UI elements, which allows us to perform testing without worrying about the
21 | /// particular UI technology used.
22 | ///
23 | /// (From http://www.codeproject.com/Articles/801986/Using-ReactiveUI-for-WinForms-MVVM-Design#xx4876432xx
24 | /// written by http://www.codeproject.com/Members/User-10914367)
25 | ///
26 | public class HomeViewModel : ReactiveUI.ReactiveObject
27 | {
28 | public HomeViewModel()
29 | {
30 | //Define conditions
31 | var okCmdObs = this.WhenAny(vm => vm.EnteredText,
32 | s => !string.IsNullOrWhiteSpace(s.Value));
33 |
34 | //Create conditions
35 | OKCmd = ReactiveCommand.Create(okCmdObs);
36 |
37 | //Update Status
38 | OKCmd.Subscribe(_ => Status = EnteredText + " is saved.");
39 | }
40 |
41 | string ModelString;
42 | public string EnteredText
43 | {
44 | get { return ModelString; }
45 | set { this.RaiseAndSetIfChanged(ref ModelString, value); }
46 | }
47 |
48 | string statusString = "";
49 | public string Status
50 | {
51 | get { return statusString; }
52 | set { this.RaiseAndSetIfChanged(ref statusString, value); }
53 | }
54 |
55 | public ReactiveCommand