Skip to content

Commit bcebeb0

Browse files
authored
Merge branch 'master' into feature/sample-app
2 parents dc75363 + d8fbfe5 commit bcebeb0

File tree

6 files changed

+91
-24
lines changed

6 files changed

+91
-24
lines changed

LICENSE

Lines changed: 0 additions & 21 deletions
This file was deleted.

README.md

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,46 @@
1-
# MVVM-Samples
2-
Sample repo for MVVM package
1+
# Windows Community Toolkit
2+
This new "MVVM Toolkit" is part of the [Windows Community Toolkit](https://aka.ms/wct). The Windows Community Toolkit is part of the [.NET Foundation](https://dotnetfoundation.org/).
3+
4+
# MVVM Toolkit & Samples
5+
6+
The MVVM library of the Windows Community Toolkit can be found in the `Microsoft.Toolkit.Mvvm` NuGet package, currently in preview. It will be known as the "MVVM Toolkit" in short for reference.
7+
8+
This repo contains initial preview [documentation](docs/mvvm/Introduction.md) and samples for how to utilize the library.
9+
10+
## Introduction to the MVVM Toolkit
11+
12+
The `Microsoft.Toolkit.Mvvm` package is a modern, fast, and modular MVVM library. It is built around the following principles:
13+
14+
- **Platform and Runtime Independent** - **.NET Standard 2.x** 🚀 (UI Framework Agnostic)
15+
- **Simple to pick-up and use** - No strict requirements on Application structure or coding-paradigms (outside of 'MVVM'ness), i.e., flexible usage.
16+
- **À la carte** - Freedom to choose which components to use.
17+
- **Reference Implementation** - Lean and performant, providing implementations for interfaces that are included in the Base Class Library, but lack concrete types to use them directly.
18+
19+
The package targets .NET Standard so it can be used on any app platform: UWP, WinForms, WPF, Xamarin, Uno, and more; and on any runtime: .NET Native, .NET Core, .NET Framework, or Mono. It runs on all of them. The API surface is identical in all cases.
20+
21+
## Background
22+
This library was inspired by [MVVMLight](https://www.mvvmlight.net/) by Laurent Bugnion. Development was started in April 2020 as a path forward for developers using MVVMLight. We've worked with Laurent, the community, and [Windows Template Studio](https://aka.ms/wts) to ensure successful migration paths for projects using MVVMLight today.
23+
24+
We decided to start from the ground-up as a new project to architect a modern .NET Standard starting point as well as targeting a high-performance implementation which reduces overhead for memory and CPU cycles. Many things in the .NET ecosystem have evolved and changed since the time MVVMLight had begun.
25+
26+
The Windows Community Toolkit seemed like a good home for this new library. This enables it to have broad support from the community, backing from the .NET Foundation, and longevity for the future.
27+
28+
We intend this library to be feature-complete and provide a common basis for app developers to create shared .NET Standard code in their applications for building with the MVVM pattern.
29+
30+
It is not our intent to add or support platform-specific features. We encourage app developers to:
31+
32+
- Use samples to understand how to integrate with their platform
33+
- Build upon this work for simplification of patterns for a specific platform
34+
- If needed, utilize other .NET Foundation supported alternatives like [MVVMCross](https://www.mvvmcross.com/) and [Prism](https://prismlibrary.com/)
35+
36+
## Contributing
37+
38+
If you find an issue with our docs or have suggestions, please file an issue in this repo for now, until our final release, when we will migrate to our main documentation repo.
39+
40+
If you'd like to help us with a sample for your own platform, please file an issue here and open up a dialog, or respond to one of the existing open issues tracking known platforms.
41+
42+
We do encourage suggestions, contributions, or platform-agnostic feature requests as well. Please open an issue to start that discussion on the [main repo here](https://github.com/windows-toolkit/WindowsCommunityToolkit).
43+
44+
## License
45+
46+
MIT

azure-pipelines.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
trigger:
2+
- master
3+
4+
pr:
5+
- master
6+
7+
pool:
8+
vmImage: 'windows-latest'
9+
10+
variables:
11+
solution: '**/*.sln'
12+
buildPlatform: 'x86|x64|ARM|ARM64'
13+
buildConfiguration: 'Release'
14+
appxPackageDir: '$(build.artifactStagingDirectory)\AppxPackages\\'
15+
16+
steps:
17+
- task: NuGetToolInstaller@1
18+
19+
- task: NuGetCommand@2
20+
inputs:
21+
restoreSolution: '$(solution)'
22+
23+
- task: VSBuild@1
24+
inputs:
25+
platform: 'x86'
26+
solution: '$(solution)'
27+
configuration: '$(buildConfiguration)'
28+
msbuildArgs: '/p:AppxBundlePlatforms="$(buildPlatform)" /p:AppxPackageDir="$(appxPackageDir)" /p:AppxBundle=Always /p:UapAppxPackageBuildMode=StoreUpload'

docs/mvvm/ObservableObject.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ public class MyModel : ObservableObject
8484

8585
Here the `SetPropertyAndNotifyOnCompletion<TTask>(ref TTask, Expression<Func<TTask>>, TTask, string)` method will take care of updating the target field, monitoring the new task, if present, and raising the notification event when that task completes. This way, it's possible to just bind to a task property and to be notified when its status changes.
8686

87+
> [!NOTE]
88+
> The `SetPropertyAndNotifyOnCompletion` method is meant to replace the usage of the `NotifyTaskCompletion<T>` type from the `Microsoft.Toolkit` package. If this type was being used, it can be replaced with just the inner `Task` (or `Task<TResult>`) property, and then the `SetPropertyAndNotifyOnCompletion` method can be used to set its value and raise notification changes. All the properties exposed by the `NotifyTaskCompletion<T>` type are available directly on `Task` instances.
89+
8790
## Sample Code
8891

8992
There are more examples in the [unit tests](https://github.com/Microsoft/WindowsCommunityToolkit//blob/master/UnitTests/UnitTests.Shared/Mvvm).

docs/mvvm/RelayCommand.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class MyViewModel : ObservableObject
3636
public int Counter
3737
{
3838
get => counter;
39-
private set => Set(ref counter, value);
39+
private set => SetProperty(ref counter, value);
4040
}
4141

4242
public ICommand IncrementCounterCommand { get; }

license.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Windows Community Toolkit
2+
3+
Copyright (c) .NET Foundation and Contributors
4+
5+
All rights reserved.
6+
7+
# MIT License (MIT)
8+
9+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
10+
11+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

0 commit comments

Comments
 (0)