├── .gitattributes
├── .gitignore
├── README.md
├── snippets
├── r#
│ └── rxui.DotSettings
└── vs
│ ├── iv4prop.snippet
│ ├── rasprop.snippet
│ └── roprop.snippet
└── src
├── complete
├── ex1-readonlyproperties
│ ├── Ex1.Tests
│ │ ├── Ex1.Tests.csproj
│ │ ├── PersonViewModelTests.cs
│ │ ├── Properties
│ │ │ └── AssemblyInfo.cs
│ │ └── packages.config
│ ├── Ex1
│ │ ├── Ex1.csproj
│ │ ├── PersonViewModel.cs
│ │ ├── Properties
│ │ │ └── AssemblyInfo.cs
│ │ └── packages.config
│ └── ex1-readonlyproperties.sln
├── ex2-reactivecommand-part1
│ ├── Ex2.Tests
│ │ ├── Ex2.Tests.csproj
│ │ ├── PersonViewModelTests.cs
│ │ ├── Properties
│ │ │ └── AssemblyInfo.cs
│ │ └── packages.config
│ ├── Ex2
│ │ ├── Ex2.csproj
│ │ ├── PersonViewModel.cs
│ │ ├── Properties
│ │ │ └── AssemblyInfo.cs
│ │ └── packages.config
│ └── ex2-reactivecommand-part1.sln
├── ex3-reactivecommand-part2
│ ├── Ex3.Tests
│ │ ├── Ex3.Tests.csproj
│ │ ├── PersonViewModelTests.cs
│ │ ├── Properties
│ │ │ └── AssemblyInfo.cs
│ │ └── packages.config
│ ├── Ex3
│ │ ├── Ex3.csproj
│ │ ├── PersonViewModel.cs
│ │ ├── Properties
│ │ │ └── AssemblyInfo.cs
│ │ └── packages.config
│ └── ex3-reactivecommand-part2.sln
├── ex4-bindings-part1
│ ├── Ex4
│ │ ├── App.config
│ │ ├── App.xaml
│ │ ├── App.xaml.cs
│ │ ├── Ex4.csproj
│ │ ├── MainWindow.xaml
│ │ ├── MainWindow.xaml.cs
│ │ ├── MainWindowModel.cs
│ │ ├── Properties
│ │ │ ├── AssemblyInfo.cs
│ │ │ ├── Resources.Designer.cs
│ │ │ ├── Resources.resx
│ │ │ ├── Settings.Designer.cs
│ │ │ └── Settings.settings
│ │ └── packages.config
│ └── ex4-bindings-part1.sln
├── ex5-viewmodel-composition
│ ├── Ex5
│ │ ├── App.config
│ │ ├── App.xaml
│ │ ├── App.xaml.cs
│ │ ├── AppBootstrapper.cs
│ │ ├── ControlStyles.ReactiveUI.xaml
│ │ ├── Ex5.csproj
│ │ ├── MainWindow.xaml
│ │ ├── MainWindow.xaml.cs
│ │ ├── MainWindowModel.cs
│ │ ├── Properties
│ │ │ ├── AssemblyInfo.cs
│ │ │ ├── Resources.Designer.cs
│ │ │ ├── Resources.resx
│ │ │ ├── Settings.Designer.cs
│ │ │ └── Settings.settings
│ │ ├── TitleBarView.xaml
│ │ ├── TitleBarView.xaml.cs
│ │ ├── TitleBarViewModel.cs
│ │ └── packages.config
│ └── ex5-viewmodel-composition.sln
├── ex6-bindings-part2
│ ├── Ex6
│ │ ├── App.config
│ │ ├── App.xaml
│ │ ├── App.xaml.cs
│ │ ├── AppBootstrapper.cs
│ │ ├── ControlStyles.ReactiveUI.xaml
│ │ ├── Ex6.csproj
│ │ ├── MainWindow.xaml
│ │ ├── MainWindow.xaml.cs
│ │ ├── MainWindowModel.cs
│ │ ├── Properties
│ │ │ ├── AssemblyInfo.cs
│ │ │ ├── Resources.Designer.cs
│ │ │ ├── Resources.resx
│ │ │ ├── Settings.Designer.cs
│ │ │ └── Settings.settings
│ │ └── packages.config
│ └── ex6-bindings-part2.sln
├── ex7-bindings-part3
│ ├── Ex7
│ │ ├── App.config
│ │ ├── App.xaml
│ │ ├── App.xaml.cs
│ │ ├── AppBootstrapper.cs
│ │ ├── ControlStyles.ReactiveUI.xaml
│ │ ├── Ex7.csproj
│ │ ├── FakeData.cs
│ │ ├── MainWindow.xaml
│ │ ├── MainWindow.xaml.cs
│ │ ├── MainWindowModel.cs
│ │ ├── Properties
│ │ │ ├── AssemblyInfo.cs
│ │ │ ├── Resources.Designer.cs
│ │ │ ├── Resources.resx
│ │ │ ├── Settings.Designer.cs
│ │ │ └── Settings.settings
│ │ ├── TweetView.xaml
│ │ ├── TweetView.xaml.cs
│ │ ├── TweetViewModel.cs
│ │ └── packages.config
│ └── ex7-bindings-part3.sln
├── ex8-routing
│ ├── Ex8
│ │ ├── App.config
│ │ ├── App.xaml
│ │ ├── App.xaml.cs
│ │ ├── AppBootstrapper.cs
│ │ ├── Ex8.csproj
│ │ ├── MainWindowView.xaml
│ │ ├── MainWindowView.xaml.cs
│ │ ├── MainWindowViewModel.cs
│ │ ├── Properties
│ │ │ ├── AssemblyInfo.cs
│ │ │ ├── Resources.Designer.cs
│ │ │ ├── Resources.resx
│ │ │ ├── Settings.Designer.cs
│ │ │ └── Settings.settings
│ │ ├── ViewA.xaml
│ │ ├── ViewA.xaml.cs
│ │ ├── ViewB.xaml
│ │ ├── ViewB.xaml.cs
│ │ ├── ViewInstanceCount.cs
│ │ ├── ViewModelA.cs
│ │ ├── ViewModelB.cs
│ │ ├── ViewModelInstanceCount.cs
│ │ └── packages.config
│ └── ex8-routing.sln
└── ex9-derivedlists
│ ├── Ex9
│ ├── App.config
│ ├── App.xaml
│ ├── App.xaml.cs
│ ├── Ex9.csproj
│ ├── MainWindow.xaml
│ ├── MainWindow.xaml.cs
│ ├── MainWindowModel.cs
│ ├── Properties
│ │ ├── AssemblyInfo.cs
│ │ ├── Resources.Designer.cs
│ │ ├── Resources.resx
│ │ ├── Settings.Designer.cs
│ │ └── Settings.settings
│ ├── TestDataSource.cs
│ ├── TestModel.cs
│ ├── TestView.xaml
│ ├── TestView.xaml.cs
│ ├── TestViewModel.cs
│ └── packages.config
│ └── ex9-derivedlists.sln
└── exercises
├── ex1-readonlyproperties
├── Ex1.Tests
│ ├── Ex1.Tests.csproj
│ ├── PersonViewModelTests.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ └── packages.config
├── Ex1
│ ├── Ex1.csproj
│ ├── PersonViewModel.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ └── packages.config
└── ex1-readonlyproperties.sln
├── ex2-reactivecommand-part1
├── Ex2.Tests
│ ├── Ex2.Tests.csproj
│ ├── PersonViewModelTests.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ └── packages.config
├── Ex2
│ ├── Ex2.csproj
│ ├── PersonViewModel.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ └── packages.config
└── ex2-reactivecommand-part1.sln
├── ex3-reactivecommand-part2
├── Ex3.Tests
│ ├── Ex3.Tests.csproj
│ ├── PersonViewModelTests.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ └── packages.config
├── Ex3
│ ├── Ex3.csproj
│ ├── PersonViewModel.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ └── packages.config
└── ex3-reactivecommand-part2.sln
├── ex4-bindings-part1
├── Ex4
│ ├── App.config
│ ├── App.xaml
│ ├── App.xaml.cs
│ ├── Ex4.csproj
│ ├── MainWindow.xaml
│ ├── MainWindow.xaml.cs
│ ├── MainWindowModel.cs
│ ├── Properties
│ │ ├── AssemblyInfo.cs
│ │ ├── Resources.Designer.cs
│ │ ├── Resources.resx
│ │ ├── Settings.Designer.cs
│ │ └── Settings.settings
│ └── packages.config
└── ex4-bindings-part1.sln
├── ex5-viewmodel-composition
├── Ex5
│ ├── App.config
│ ├── App.xaml
│ ├── App.xaml.cs
│ ├── AppBootstrapper.cs
│ ├── ControlStyles.ReactiveUI.xaml
│ ├── Ex5.csproj
│ ├── MainWindow.xaml
│ ├── MainWindow.xaml.cs
│ ├── MainWindowModel.cs
│ ├── Properties
│ │ ├── AssemblyInfo.cs
│ │ ├── Resources.Designer.cs
│ │ ├── Resources.resx
│ │ ├── Settings.Designer.cs
│ │ └── Settings.settings
│ ├── TitleBarView.xaml
│ ├── TitleBarView.xaml.cs
│ ├── TitleBarViewModel.cs
│ └── packages.config
└── ex5-viewmodel-composition.sln
├── ex6-bindings-part2
├── Ex6
│ ├── App.config
│ ├── App.xaml
│ ├── App.xaml.cs
│ ├── AppBootstrapper.cs
│ ├── ControlStyles.ReactiveUI.xaml
│ ├── Ex6.csproj
│ ├── MainWindow.xaml
│ ├── MainWindow.xaml.cs
│ ├── MainWindowModel.cs
│ ├── Properties
│ │ ├── AssemblyInfo.cs
│ │ ├── Resources.Designer.cs
│ │ ├── Resources.resx
│ │ ├── Settings.Designer.cs
│ │ └── Settings.settings
│ └── packages.config
└── ex6-bindings-part2.sln
├── ex7-bindings-part3
├── Ex7
│ ├── App.config
│ ├── App.xaml
│ ├── App.xaml.cs
│ ├── AppBootstrapper.cs
│ ├── ControlStyles.ReactiveUI.xaml
│ ├── Ex7.csproj
│ ├── FakeData.cs
│ ├── MainWindow.xaml
│ ├── MainWindow.xaml.cs
│ ├── MainWindowModel.cs
│ ├── Properties
│ │ ├── AssemblyInfo.cs
│ │ ├── Resources.Designer.cs
│ │ ├── Resources.resx
│ │ ├── Settings.Designer.cs
│ │ └── Settings.settings
│ ├── TweetView.xaml
│ ├── TweetView.xaml.cs
│ ├── TweetViewModel.cs
│ └── packages.config
└── ex7-bindings-part3.sln
├── ex8-routing
├── Ex8
│ ├── App.config
│ ├── App.xaml
│ ├── App.xaml.cs
│ ├── AppBootstrapper.cs
│ ├── Ex8.csproj
│ ├── MainWindowView.xaml
│ ├── MainWindowView.xaml.cs
│ ├── MainWindowViewModel.cs
│ ├── Properties
│ │ ├── AssemblyInfo.cs
│ │ ├── Resources.Designer.cs
│ │ ├── Resources.resx
│ │ ├── Settings.Designer.cs
│ │ └── Settings.settings
│ ├── ViewA.xaml
│ ├── ViewA.xaml.cs
│ ├── ViewB.xaml
│ ├── ViewB.xaml.cs
│ ├── ViewInstanceCount.cs
│ ├── ViewModelA.cs
│ ├── ViewModelB.cs
│ ├── ViewModelInstanceCount.cs
│ └── packages.config
└── ex8-routing.sln
└── ex9-derivedlists
├── Ex9
├── App.config
├── App.xaml
├── App.xaml.cs
├── Ex9.csproj
├── MainWindow.xaml
├── MainWindow.xaml.cs
├── MainWindowModel.cs
├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
├── TestDataSource.cs
├── TestModel.cs
├── TestView.xaml
├── TestView.xaml.cs
├── TestViewModel.cs
└── packages.config
└── ex9-derivedlists.sln
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 | *.sln merge=union
7 | *.csproj merge=union
8 | *.vbproj merge=union
9 | *.fsproj merge=union
10 | *.dbproj merge=union
11 |
12 | # Standard to msysgit
13 | *.doc diff=astextplain
14 | *.DOC diff=astextplain
15 | *.docx diff=astextplain
16 | *.DOCX diff=astextplain
17 | *.dot diff=astextplain
18 | *.DOT diff=astextplain
19 | *.pdf diff=astextplain
20 | *.PDF diff=astextplain
21 | *.rtf diff=astextplain
22 | *.RTF diff=astextplain
23 |
--------------------------------------------------------------------------------
/snippets/vs/iv4prop.snippet:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IViewForProp
6 | iv4prop
7 | Generates the dependency prop for IViewFor
8 |
9 | Expansion
10 |
11 |
12 |
13 |
14 |
15 | classname
16 | View type
17 | ClassName()
18 | ClassNamePlaceholder
19 |
20 |
21 |
22 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/snippets/vs/rasprop.snippet:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | RaiseAndSetProp
6 | rasprop
7 | Generates ReactiveUI RaiseAndSetIfChanged property
8 |
9 | Expansion
10 |
11 |
12 |
13 |
14 |
15 | type
16 | Property type
17 | string
18 |
19 |
20 | propName
21 | MyNotProp
22 | The property name
23 |
24 |
25 |
26 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/snippets/vs/roprop.snippet:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | RaiseAndSetProp
6 | roprop
7 | Generates ReactiveUI read-only property
8 |
9 | Expansion
10 |
11 |
12 |
13 |
14 |
15 | type
16 | Property type
17 | string
18 |
19 |
20 | propName
21 | MyNotProp
22 | The property name
23 |
24 |
25 |
26 | _$propName$;
27 | public $type$ $propName$
28 | {
29 | get { return _$propName$.Value; }
30 | }$end$]]>
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/src/complete/ex1-readonlyproperties/Ex1.Tests/PersonViewModelTests.cs:
--------------------------------------------------------------------------------
1 | using NUnit.Framework;
2 |
3 | namespace Ex1.Tests
4 | {
5 | [TestFixture]
6 | public class PersonViewModelTests
7 | {
8 | [Test]
9 | public void FullNameIsMadeUpFromFirstNameAndLastName()
10 | {
11 | var sut = new PersonViewModel {FirstName = "Jane", LastName = "Appleseed"};
12 |
13 | Assert.AreEqual("Jane Appleseed", sut.FullName);
14 | }
15 |
16 | [Test]
17 | public void FullNameUpdatesWhenFirstNameChanges()
18 | {
19 | var sut = new PersonViewModel {FirstName = "Jane", LastName = "Appleseed"};
20 | sut.FirstName = "Joe";
21 |
22 | Assert.AreEqual("Joe Appleseed", sut.FullName);
23 | }
24 |
25 | [Test]
26 | public void FullNameUpdatesWhenLastNameChanges()
27 | {
28 | var sut = new PersonViewModel {FirstName = "Jane", LastName = "Appleseed"};
29 | sut.LastName = "Smith";
30 |
31 | Assert.AreEqual("Jane Smith", sut.FullName);
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/complete/ex1-readonlyproperties/Ex1.Tests/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("Ex1.Tests")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Vagrant Inc.")]
12 | [assembly: AssemblyProduct("Ex1.Tests")]
13 | [assembly: AssemblyCopyright("Copyright © Vagrant Inc. 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("f652787a-af8e-4b17-b662-eeeefa6ff48c")]
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 |
--------------------------------------------------------------------------------
/src/complete/ex1-readonlyproperties/Ex1.Tests/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/src/complete/ex1-readonlyproperties/Ex1/PersonViewModel.cs:
--------------------------------------------------------------------------------
1 | using ReactiveUI;
2 |
3 | namespace Ex1
4 | {
5 | public class PersonViewModel : ReactiveObject
6 | {
7 | public PersonViewModel()
8 | {
9 | _fullName = this.WhenAnyValue(vm => vm.FirstName, vm => vm.LastName, (f, l) => string.Format("{0} {1}", f, l))
10 | .ToProperty(this, vm => vm.FullName);
11 | }
12 |
13 | private readonly ObservableAsPropertyHelper _fullName;
14 | public string FullName
15 | {
16 | get { return _fullName.Value; }
17 | }
18 |
19 | private string _firstName;
20 | public string FirstName
21 | {
22 | get { return _firstName; }
23 | set { this.RaiseAndSetIfChanged(ref _firstName, value); }
24 | }
25 |
26 | private string _lastName;
27 | public string LastName
28 | {
29 | get { return _lastName; }
30 | set { this.RaiseAndSetIfChanged(ref _lastName, value); }
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/complete/ex1-readonlyproperties/Ex1/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("Ex1")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Vagrant Inc.")]
12 | [assembly: AssemblyProduct("Ex1")]
13 | [assembly: AssemblyCopyright("Copyright © Vagrant Inc. 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("3cfe10f3-975a-4e5c-85e2-6ee359a4897e")]
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 |
--------------------------------------------------------------------------------
/src/complete/ex1-readonlyproperties/Ex1/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/src/complete/ex1-readonlyproperties/ex1-readonlyproperties.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2013
4 | VisualStudioVersion = 12.0.30110.0
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ex1.Tests", "Ex1.Tests\Ex1.Tests.csproj", "{9A729109-8D64-4AA6-8331-B238AAC0E3C7}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ex1", "Ex1\Ex1.csproj", "{403F8DE4-409C-4259-BF3D-A1E20AD30739}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|Any CPU = Debug|Any CPU
13 | Release|Any CPU = Release|Any CPU
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {9A729109-8D64-4AA6-8331-B238AAC0E3C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17 | {9A729109-8D64-4AA6-8331-B238AAC0E3C7}.Debug|Any CPU.Build.0 = Debug|Any CPU
18 | {9A729109-8D64-4AA6-8331-B238AAC0E3C7}.Release|Any CPU.ActiveCfg = Release|Any CPU
19 | {9A729109-8D64-4AA6-8331-B238AAC0E3C7}.Release|Any CPU.Build.0 = Release|Any CPU
20 | {403F8DE4-409C-4259-BF3D-A1E20AD30739}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21 | {403F8DE4-409C-4259-BF3D-A1E20AD30739}.Debug|Any CPU.Build.0 = Debug|Any CPU
22 | {403F8DE4-409C-4259-BF3D-A1E20AD30739}.Release|Any CPU.ActiveCfg = Release|Any CPU
23 | {403F8DE4-409C-4259-BF3D-A1E20AD30739}.Release|Any CPU.Build.0 = Release|Any CPU
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | EndGlobal
29 |
--------------------------------------------------------------------------------
/src/complete/ex2-reactivecommand-part1/Ex2.Tests/PersonViewModelTests.cs:
--------------------------------------------------------------------------------
1 | using NUnit.Framework;
2 |
3 | namespace Ex2.Tests
4 | {
5 | [TestFixture]
6 | public class PersonViewModelTests
7 | {
8 | [Test]
9 | public void ChangeNameCanOnlyBeExecutedIfFirstNameAndLastNameAreFilled()
10 | {
11 | var sut = new PersonViewModel();
12 |
13 | Assert.IsFalse(sut.ChangeName.CanExecute(null));
14 |
15 | sut.FirstName = "Jane";
16 |
17 | Assert.IsFalse(sut.ChangeName.CanExecute(null));
18 |
19 | sut.LastName = "Appleseed";
20 |
21 | Assert.IsTrue(sut.ChangeName.CanExecute(null));
22 | }
23 |
24 | [Test]
25 | public void FullNameIsMadeUpFromFirstNameAndLastName()
26 | {
27 | var sut = new PersonViewModel { FirstName = "Jane", LastName = "Appleseed" };
28 |
29 | Assert.AreEqual("Jane Appleseed", sut.FullName);
30 | }
31 |
32 | [Test]
33 | public void FullNameUpdatesWhenFirstNameChanges()
34 | {
35 | var sut = new PersonViewModel { FirstName = "Jane", LastName = "Appleseed" };
36 | sut.FirstName = "Joe";
37 |
38 | Assert.AreEqual("Joe Appleseed", sut.FullName);
39 | }
40 |
41 | [Test]
42 | public void FullNameUpdatesWhenLastNameChanges()
43 | {
44 | var sut = new PersonViewModel { FirstName = "Jane", LastName = "Appleseed" };
45 | sut.LastName = "Smith";
46 |
47 | Assert.AreEqual("Jane Smith", sut.FullName);
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/complete/ex2-reactivecommand-part1/Ex2.Tests/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("Ex2.Tests")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Vagrant Inc.")]
12 | [assembly: AssemblyProduct("Ex2.Tests")]
13 | [assembly: AssemblyCopyright("Copyright © Vagrant Inc. 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("b5463a2f-f921-472a-acf1-c44d83fce768")]
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 |
--------------------------------------------------------------------------------
/src/complete/ex2-reactivecommand-part1/Ex2.Tests/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/src/complete/ex2-reactivecommand-part1/Ex2/PersonViewModel.cs:
--------------------------------------------------------------------------------
1 | using ReactiveUI;
2 |
3 | namespace Ex2
4 | {
5 | public class PersonViewModel : ReactiveObject
6 | {
7 | public PersonViewModel()
8 | {
9 | _fullName = this.WhenAnyValue(vm => vm.FirstName, vm => vm.LastName, (f, l) => string.Format("{0} {1}", f, l))
10 | .ToProperty(this, vm => vm.FullName);
11 |
12 | var firstAndLastFilled = this.WhenAnyValue(vm => vm.FirstName, vm => vm.LastName,
13 | (f, l) => !string.IsNullOrWhiteSpace(f) && !string.IsNullOrWhiteSpace(l));
14 | ChangeName = ReactiveCommand.Create(firstAndLastFilled);
15 | }
16 |
17 | public readonly IReactiveCommand ChangeName;
18 |
19 | private readonly ObservableAsPropertyHelper _fullName;
20 | public string FullName
21 | {
22 | get { return _fullName.Value; }
23 | }
24 |
25 | private string _firstName;
26 | public string FirstName
27 | {
28 | get { return _firstName; }
29 | set { this.RaiseAndSetIfChanged(ref _firstName, value); }
30 | }
31 |
32 | private string _lastName;
33 | public string LastName
34 | {
35 | get { return _lastName; }
36 | set { this.RaiseAndSetIfChanged(ref _lastName, value); }
37 | }
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/src/complete/ex2-reactivecommand-part1/Ex2/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("Ex2")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Vagrant Inc.")]
12 | [assembly: AssemblyProduct("Ex2")]
13 | [assembly: AssemblyCopyright("Copyright © Vagrant Inc. 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("c7c35797-0198-4fce-822f-1231979824bd")]
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 |
--------------------------------------------------------------------------------
/src/complete/ex2-reactivecommand-part1/Ex2/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/src/complete/ex2-reactivecommand-part1/ex2-reactivecommand-part1.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2013
4 | VisualStudioVersion = 12.0.30110.0
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ex2.Tests", "Ex2.Tests\Ex2.Tests.csproj", "{7B54550F-D810-4F3B-B880-F87B990D5904}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ex2", "Ex2\Ex2.csproj", "{C50CA0FE-1323-4ED6-BB2B-AF123B4D3EE5}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|Any CPU = Debug|Any CPU
13 | Release|Any CPU = Release|Any CPU
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {7B54550F-D810-4F3B-B880-F87B990D5904}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17 | {7B54550F-D810-4F3B-B880-F87B990D5904}.Debug|Any CPU.Build.0 = Debug|Any CPU
18 | {7B54550F-D810-4F3B-B880-F87B990D5904}.Release|Any CPU.ActiveCfg = Release|Any CPU
19 | {7B54550F-D810-4F3B-B880-F87B990D5904}.Release|Any CPU.Build.0 = Release|Any CPU
20 | {C50CA0FE-1323-4ED6-BB2B-AF123B4D3EE5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21 | {C50CA0FE-1323-4ED6-BB2B-AF123B4D3EE5}.Debug|Any CPU.Build.0 = Debug|Any CPU
22 | {C50CA0FE-1323-4ED6-BB2B-AF123B4D3EE5}.Release|Any CPU.ActiveCfg = Release|Any CPU
23 | {C50CA0FE-1323-4ED6-BB2B-AF123B4D3EE5}.Release|Any CPU.Build.0 = Release|Any CPU
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | EndGlobal
29 |
--------------------------------------------------------------------------------
/src/complete/ex3-reactivecommand-part2/Ex3.Tests/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("Ex3.Tests")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Vagrant Inc.")]
12 | [assembly: AssemblyProduct("Ex3.Tests")]
13 | [assembly: AssemblyCopyright("Copyright © Vagrant Inc. 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("b5463a2f-f921-472a-acf1-c44d83fce768")]
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 |
--------------------------------------------------------------------------------
/src/complete/ex3-reactivecommand-part2/Ex3.Tests/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/src/complete/ex3-reactivecommand-part2/Ex3/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("Ex3")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Vagrant Inc.")]
12 | [assembly: AssemblyProduct("Ex3")]
13 | [assembly: AssemblyCopyright("Copyright © Vagrant Inc. 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("c7c35797-0198-4fce-822f-1231979824bd")]
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 |
--------------------------------------------------------------------------------
/src/complete/ex3-reactivecommand-part2/Ex3/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/src/complete/ex3-reactivecommand-part2/ex3-reactivecommand-part2.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2013
4 | VisualStudioVersion = 12.0.30110.0
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ex3", "Ex3\Ex3.csproj", "{C50CA0FE-1323-4ED6-BB2B-AF123B4D3EE5}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ex3.Tests", "Ex3.Tests\Ex3.Tests.csproj", "{7B54550F-D810-4F3B-B880-F87B990D5904}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|Any CPU = Debug|Any CPU
13 | Release|Any CPU = Release|Any CPU
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {C50CA0FE-1323-4ED6-BB2B-AF123B4D3EE5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17 | {C50CA0FE-1323-4ED6-BB2B-AF123B4D3EE5}.Debug|Any CPU.Build.0 = Debug|Any CPU
18 | {C50CA0FE-1323-4ED6-BB2B-AF123B4D3EE5}.Release|Any CPU.ActiveCfg = Release|Any CPU
19 | {C50CA0FE-1323-4ED6-BB2B-AF123B4D3EE5}.Release|Any CPU.Build.0 = Release|Any CPU
20 | {7B54550F-D810-4F3B-B880-F87B990D5904}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21 | {7B54550F-D810-4F3B-B880-F87B990D5904}.Debug|Any CPU.Build.0 = Debug|Any CPU
22 | {7B54550F-D810-4F3B-B880-F87B990D5904}.Release|Any CPU.ActiveCfg = Release|Any CPU
23 | {7B54550F-D810-4F3B-B880-F87B990D5904}.Release|Any CPU.Build.0 = Release|Any CPU
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | EndGlobal
29 |
--------------------------------------------------------------------------------
/src/complete/ex4-bindings-part1/Ex4/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/complete/ex4-bindings-part1/Ex4/App.xaml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/src/complete/ex4-bindings-part1/Ex4/App.xaml.cs:
--------------------------------------------------------------------------------
1 | namespace Ex4
2 | {
3 | public partial class App
4 | {
5 | public App()
6 | {
7 | var vm = new MainWindowModel();
8 | var view = new MainWindow {ViewModel = vm};
9 |
10 | view.ShowDialog();
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/complete/ex4-bindings-part1/Ex4/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
9 |
12 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 | First Name:
28 |
29 | Last Name:
30 |
31 |
32 |
33 |
34 |
35 | Server Response:
36 |
37 |
38 |
--------------------------------------------------------------------------------
/src/complete/ex4-bindings-part1/Ex4/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 | using ReactiveUI;
3 |
4 | namespace Ex4
5 | {
6 | public partial class MainWindow : IViewFor
7 | {
8 | public MainWindow()
9 | {
10 | InitializeComponent();
11 |
12 | this.WhenActivated(d =>
13 | {
14 | d(this.Bind(ViewModel, vm => vm.FirstName, v => v.FirstName.Text));
15 | d(this.Bind(ViewModel, vm => vm.LastName, v => v.LastName.Text));
16 | d(this.OneWayBind(ViewModel, vm => vm.ServerResult, v => v.ServerResult.Text));
17 | d(this.BindCommand(ViewModel, vm => vm.ChangeName, v => v.ChangeNameButton));
18 | });
19 | }
20 |
21 | public static readonly DependencyProperty ViewModelProperty;
22 |
23 | static MainWindow()
24 | {
25 | ViewModelProperty = DependencyProperty.Register("ViewModel", typeof(MainWindowModel), typeof(MainWindow));
26 | }
27 |
28 | public MainWindowModel ViewModel
29 | {
30 | get { return (MainWindowModel)GetValue(ViewModelProperty); }
31 | set { SetValue(ViewModelProperty, value); }
32 | }
33 |
34 | object IViewFor.ViewModel
35 | {
36 | get { return ViewModel; }
37 | set { ViewModel = (MainWindowModel)value; }
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/complete/ex4-bindings-part1/Ex4/MainWindowModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading.Tasks;
3 | using ReactiveUI;
4 |
5 | namespace Ex4
6 | {
7 | public class MainWindowModel : ReactiveObject
8 | {
9 | private async Task PretendToCallTheServer()
10 | {
11 | await Task.Delay(2000);
12 | return "Hello World";
13 | }
14 |
15 | public MainWindowModel()
16 | {
17 | ServerResult = "Haven't talked to the server yet...";
18 |
19 | var firstAndLastFilled = this.WhenAnyValue(vm => vm.FirstName, vm => vm.LastName,
20 | (f, l) => !string.IsNullOrWhiteSpace(f) && !string.IsNullOrWhiteSpace(l));
21 |
22 | ChangeName = ReactiveCommand.CreateAsyncTask(firstAndLastFilled, _ => PretendToCallTheServer());
23 | ChangeName.Subscribe(r => ServerResult = r);
24 | }
25 |
26 | private string _serverResult;
27 | public string ServerResult
28 | {
29 | get { return _serverResult; }
30 | set { this.RaiseAndSetIfChanged(ref _serverResult, value); }
31 | }
32 |
33 | public readonly ReactiveCommand ChangeName;
34 |
35 | private string _firstName;
36 | public string FirstName
37 | {
38 | get { return _firstName; }
39 | set { this.RaiseAndSetIfChanged(ref _firstName, value); }
40 | }
41 |
42 | private string _lastName;
43 | public string LastName
44 | {
45 | get { return _lastName; }
46 | set { this.RaiseAndSetIfChanged(ref _lastName, value); }
47 | }
48 | }
49 | }
--------------------------------------------------------------------------------
/src/complete/ex4-bindings-part1/Ex4/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 Ex4.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 |
--------------------------------------------------------------------------------
/src/complete/ex4-bindings-part1/Ex4/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/src/complete/ex4-bindings-part1/Ex4/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/src/complete/ex4-bindings-part1/ex4-bindings-part1.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2013
4 | VisualStudioVersion = 12.0.30110.0
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ex4", "Ex4\Ex4.csproj", "{39BDFDD2-F246-4807-ADCB-30A1E44A52E2}"
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 | {39BDFDD2-F246-4807-ADCB-30A1E44A52E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {39BDFDD2-F246-4807-ADCB-30A1E44A52E2}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {39BDFDD2-F246-4807-ADCB-30A1E44A52E2}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {39BDFDD2-F246-4807-ADCB-30A1E44A52E2}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | EndGlobal
23 |
--------------------------------------------------------------------------------
/src/complete/ex5-viewmodel-composition/Ex5/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/complete/ex5-viewmodel-composition/Ex5/App.xaml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/src/complete/ex5-viewmodel-composition/Ex5/App.xaml.cs:
--------------------------------------------------------------------------------
1 | namespace Ex5
2 | {
3 | public partial class App
4 | {
5 | public App()
6 | {
7 | InitializeComponent();
8 | (new AppBootstrapper()).Bootstrap();
9 | }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/complete/ex5-viewmodel-composition/Ex5/AppBootstrapper.cs:
--------------------------------------------------------------------------------
1 | using ReactiveUI;
2 | using Splat;
3 |
4 | namespace Ex5
5 | {
6 | public class AppBootstrapper
7 | {
8 | public void Bootstrap()
9 | {
10 | ConfigureServiceLocator();
11 | RunApp();
12 | }
13 |
14 | private void ConfigureServiceLocator()
15 | {
16 | var sl = Locator.CurrentMutable;
17 |
18 | sl.Register(() => new TitleBarView(), typeof(IViewFor));
19 | }
20 |
21 | private void RunApp()
22 | {
23 | var vm = new MainWindowModel();
24 | var view = new MainWindow {ViewModel = vm};
25 |
26 | view.ShowDialog();
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/src/complete/ex5-viewmodel-composition/Ex5/ControlStyles.ReactiveUI.xaml:
--------------------------------------------------------------------------------
1 |
4 |
9 |
--------------------------------------------------------------------------------
/src/complete/ex5-viewmodel-composition/Ex5/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
10 |
13 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 | First Name:
31 |
32 | Last Name:
33 |
34 |
35 |
36 |
37 |
38 | Server Response:
39 |
40 |
41 |
--------------------------------------------------------------------------------
/src/complete/ex5-viewmodel-composition/Ex5/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 | using ReactiveUI;
3 |
4 | namespace Ex5
5 | {
6 | public partial class MainWindow : IViewFor
7 | {
8 | public MainWindow()
9 | {
10 | InitializeComponent();
11 |
12 | this.WhenActivated(d =>
13 | {
14 | d(this.OneWayBind(ViewModel, vm => vm.TitleBar, v => v.TitleBarHost.ViewModel));
15 | d(this.Bind(ViewModel, vm => vm.FirstName, v => v.FirstName.Text));
16 | d(this.Bind(ViewModel, vm => vm.LastName, v => v.LastName.Text));
17 | d(this.OneWayBind(ViewModel, vm => vm.ServerResult, v => v.ServerResult.Text));
18 | d(this.BindCommand(ViewModel, vm => vm.ChangeName, v => v.ChangeNameButton));
19 | });
20 | }
21 |
22 | public static readonly DependencyProperty ViewModelProperty;
23 |
24 | static MainWindow()
25 | {
26 | ViewModelProperty = DependencyProperty.Register("ViewModel", typeof(MainWindowModel), typeof(MainWindow));
27 | }
28 |
29 | public MainWindowModel ViewModel
30 | {
31 | get { return (MainWindowModel)GetValue(ViewModelProperty); }
32 | set { SetValue(ViewModelProperty, value); }
33 | }
34 |
35 | object IViewFor.ViewModel
36 | {
37 | get { return ViewModel; }
38 | set { ViewModel = (MainWindowModel)value; }
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/complete/ex5-viewmodel-composition/Ex5/MainWindowModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reactive.Linq;
3 | using System.Threading.Tasks;
4 | using ReactiveUI;
5 |
6 | namespace Ex5
7 | {
8 | public class MainWindowModel : ReactiveObject
9 | {
10 | private async Task PretendToCallTheServer()
11 | {
12 | await Task.Delay(2000);
13 | return "Hello World";
14 | }
15 |
16 | public MainWindowModel()
17 | {
18 | TitleBar = new TitleBarViewModel();
19 |
20 | ServerResult = "Haven't talked to the server yet...";
21 |
22 | var firstAndLastFilled = this.WhenAnyValue(vm => vm.FirstName, vm => vm.LastName,
23 | (f, l) => !string.IsNullOrWhiteSpace(f) && !string.IsNullOrWhiteSpace(l));
24 |
25 | ChangeName = ReactiveCommand.CreateAsyncTask(firstAndLastFilled, _ => PretendToCallTheServer());
26 | ChangeName.Subscribe(r => ServerResult = r);
27 | }
28 |
29 | private TitleBarViewModel _titleBar;
30 | public TitleBarViewModel TitleBar
31 | {
32 | get { return _titleBar; }
33 | private set { this.RaiseAndSetIfChanged(ref _titleBar, value); }
34 | }
35 |
36 | private string _serverResult;
37 | public string ServerResult
38 | {
39 | get { return _serverResult; }
40 | set { this.RaiseAndSetIfChanged(ref _serverResult, value); }
41 | }
42 |
43 | public readonly ReactiveCommand ChangeName;
44 |
45 | private string _firstName;
46 | public string FirstName
47 | {
48 | get { return _firstName; }
49 | set { this.RaiseAndSetIfChanged(ref _firstName, value); }
50 | }
51 |
52 | private string _lastName;
53 | public string LastName
54 | {
55 | get { return _lastName; }
56 | set { this.RaiseAndSetIfChanged(ref _lastName, value); }
57 | }
58 | }
59 | }
--------------------------------------------------------------------------------
/src/complete/ex5-viewmodel-composition/Ex5/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 Ex5.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/complete/ex5-viewmodel-composition/Ex5/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/src/complete/ex5-viewmodel-composition/Ex5/TitleBarView.xaml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/src/complete/ex5-viewmodel-composition/Ex5/TitleBarView.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 | using ReactiveUI;
3 |
4 | namespace Ex5
5 | {
6 | public partial class TitleBarView : IViewFor
7 | {
8 | public TitleBarView()
9 | {
10 | InitializeComponent();
11 |
12 | this.WhenActivated(d => d(this.OneWayBind(ViewModel, vm => vm.Title, v => v.Title.Text)));
13 | }
14 |
15 | public static readonly DependencyProperty ViewModelProperty;
16 |
17 | static TitleBarView()
18 | {
19 | ViewModelProperty = DependencyProperty.Register("ViewModel", typeof(TitleBarViewModel), typeof(TitleBarView));
20 | }
21 |
22 | public TitleBarViewModel ViewModel
23 | {
24 | get { return (TitleBarViewModel)GetValue(ViewModelProperty); }
25 | set { SetValue(ViewModelProperty, value); }
26 | }
27 |
28 | object IViewFor.ViewModel
29 | {
30 | get { return ViewModel; }
31 | set { ViewModel = (TitleBarViewModel)value; }
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/complete/ex5-viewmodel-composition/Ex5/TitleBarViewModel.cs:
--------------------------------------------------------------------------------
1 | using ReactiveUI;
2 |
3 | namespace Ex5
4 | {
5 | public class TitleBarViewModel : ReactiveObject
6 | {
7 | public TitleBarViewModel()
8 | {
9 | Title = "This is being composed from TitleBarViewModel";
10 | }
11 |
12 | private string _title;
13 | public string Title
14 | {
15 | get { return _title; }
16 | set { this.RaiseAndSetIfChanged(ref _title, value); }
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/complete/ex5-viewmodel-composition/Ex5/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/src/complete/ex5-viewmodel-composition/ex5-viewmodel-composition.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2013
4 | VisualStudioVersion = 12.0.30110.0
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ex5", "Ex5\Ex5.csproj", "{39BDFDD2-F246-4807-ADCB-30A1E44A52E2}"
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 | {39BDFDD2-F246-4807-ADCB-30A1E44A52E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {39BDFDD2-F246-4807-ADCB-30A1E44A52E2}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {39BDFDD2-F246-4807-ADCB-30A1E44A52E2}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {39BDFDD2-F246-4807-ADCB-30A1E44A52E2}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | EndGlobal
23 |
--------------------------------------------------------------------------------
/src/complete/ex6-bindings-part2/Ex6/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/complete/ex6-bindings-part2/Ex6/App.xaml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/src/complete/ex6-bindings-part2/Ex6/App.xaml.cs:
--------------------------------------------------------------------------------
1 | namespace Ex6
2 | {
3 | public partial class App
4 | {
5 | public App()
6 | {
7 | InitializeComponent();
8 | (new AppBootstrapper()).Bootstrap();
9 | }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/complete/ex6-bindings-part2/Ex6/AppBootstrapper.cs:
--------------------------------------------------------------------------------
1 | namespace Ex6
2 | {
3 | public class AppBootstrapper
4 | {
5 | public void Bootstrap()
6 | {
7 | RunApp();
8 | }
9 |
10 | private void RunApp()
11 | {
12 | var vm = new MainWindowModel();
13 | var view = new MainWindow {ViewModel = vm};
14 |
15 | view.ShowDialog();
16 | }
17 | }
18 | }
--------------------------------------------------------------------------------
/src/complete/ex6-bindings-part2/Ex6/ControlStyles.ReactiveUI.xaml:
--------------------------------------------------------------------------------
1 |
4 |
9 |
--------------------------------------------------------------------------------
/src/complete/ex6-bindings-part2/Ex6/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
9 |
12 |
15 |
16 |
17 |
18 | Name:
19 |
20 |
21 |
22 |
23 |
24 | Entered Text:
25 |
26 |
27 |
--------------------------------------------------------------------------------
/src/complete/ex6-bindings-part2/Ex6/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows;
3 | using ReactiveUI;
4 |
5 | namespace Ex6
6 | {
7 | public partial class MainWindow : IViewFor
8 | {
9 | public MainWindow()
10 | {
11 | InitializeComponent();
12 |
13 | this.WhenActivated(d =>
14 | {
15 | d(ViewModel.GreetUser.Subscribe(_ =>
16 | MessageBox.Show(string.Format("Hello {0}", ViewModel.FirstName))));
17 |
18 | d(this.Bind(ViewModel, vm => vm.FirstName, v => v.FirstName.Text));
19 | d(this.BindCommand(ViewModel, vm => vm.GreetUser, v => v.GreetUserButton));
20 |
21 | d(ViewModel.WhenAnyValue(vm => vm.FirstName).BindTo(this, v => v.WhatWasEntered.Text));
22 | });
23 |
24 | }
25 |
26 | public static readonly DependencyProperty ViewModelProperty;
27 |
28 | static MainWindow()
29 | {
30 | ViewModelProperty = DependencyProperty.Register("ViewModel", typeof(MainWindowModel), typeof(MainWindow));
31 | }
32 |
33 | public MainWindowModel ViewModel
34 | {
35 | get { return (MainWindowModel)GetValue(ViewModelProperty); }
36 | set { SetValue(ViewModelProperty, value); }
37 | }
38 |
39 | object IViewFor.ViewModel
40 | {
41 | get { return ViewModel; }
42 | set { ViewModel = (MainWindowModel)value; }
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/complete/ex6-bindings-part2/Ex6/MainWindowModel.cs:
--------------------------------------------------------------------------------
1 | using ReactiveUI;
2 |
3 | namespace Ex6
4 | {
5 | public class MainWindowModel : ReactiveObject
6 | {
7 | public MainWindowModel()
8 | {
9 | var canGreet = this.WhenAnyValue(vm => vm.FirstName, n => !string.IsNullOrWhiteSpace(n));
10 | GreetUser = ReactiveCommand.Create(canGreet);
11 | }
12 |
13 | public readonly ReactiveCommand