Skip to content

Commit 56f83c6

Browse files
authored
Merge branch 'master' into i17-MigrateMvvmBasic
2 parents 015a509 + 1c5a2f4 commit 56f83c6

File tree

6 files changed

+36
-36
lines changed

6 files changed

+36
-36
lines changed

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).

samples/MvvmSampleUwp/MvvmSampleUwp/MvvmSampleUwp.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,13 +260,13 @@
260260
<Version>6.2.10</Version>
261261
</PackageReference>
262262
<PackageReference Include="Microsoft.Toolkit">
263-
<Version>7.0.0-build.152</Version>
263+
<Version>7.0.0-preview2</Version>
264264
</PackageReference>
265265
<PackageReference Include="Microsoft.Toolkit.Mvvm">
266-
<Version>7.0.0-build.149</Version>
266+
<Version>7.0.0-preview2</Version>
267267
</PackageReference>
268268
<PackageReference Include="Microsoft.Toolkit.Uwp.UI.Controls">
269-
<Version>7.0.0-build.152</Version>
269+
<Version>7.0.0-preview2</Version>
270270
</PackageReference>
271271
<PackageReference Include="Microsoft.UI.Xaml">
272272
<Version>2.4.2</Version>

samples/MvvmSampleUwp/MvvmSampleUwp/Views/AsyncRelayCommandPage.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
xmlns:toolkit="using:Microsoft.Toolkit.Uwp.UI.Controls"
88
xmlns:controls="using:MvvmSampleUwp.Controls"
99
xmlns:viewModels="using:MvvmSampleUwp.ViewModels"
10-
xmlns:views="using:MvvmSampleUwp.Views"
1110
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
1211
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
1312
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
13+
xmlns:converters="using:Microsoft.Toolkit.Uwp.UI.Converters"
1414
mc:Ignorable="d"
1515
NavigationCacheMode="Enabled">
1616
<Page.DataContext>
@@ -22,7 +22,7 @@
2222
</core:EventTriggerBehavior>
2323
</interactivity:Interaction.Behaviors>
2424
<Page.Resources>
25-
<views:TaskResultConverter x:Key="TaskResultConverter"/>
25+
<converters:TaskResultConverter x:Key="TaskResultConverter"/>
2626
</Page.Resources>
2727

2828
<ScrollViewer Padding="16" CanContentRenderOutsideBounds="True">

samples/MvvmSampleUwp/MvvmSampleUwp/Views/AsyncRelayCommandPage.xaml.cs

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5-
using System;
6-
using System.Threading.Tasks;
75
using Windows.UI.Xaml.Controls;
8-
using Windows.UI.Xaml.Data;
96

107
namespace MvvmSampleUwp.Views
118
{
@@ -19,26 +16,4 @@ public AsyncRelayCommandPage()
1916
this.InitializeComponent();
2017
}
2118
}
22-
23-
// TODO: replace this with the one from the toolkit, when https://github.com/windows-toolkit/WindowsCommunityToolkit/pull/3410 is merged
24-
public sealed class TaskResultConverter : IValueConverter
25-
{
26-
/// <inheritdoc/>
27-
public object Convert(object value, Type targetType, object parameter, string language)
28-
{
29-
if (value is Task task &&
30-
task.IsCompletedSuccessfully)
31-
{
32-
return task.GetType().GetProperty(nameof(Task<object>.Result))?.GetValue(task);
33-
}
34-
35-
return null;
36-
}
37-
38-
/// <inheritdoc/>
39-
public object ConvertBack(object value, Type targetType, object parameter, string language)
40-
{
41-
throw new NotImplementedException();
42-
}
43-
}
4419
}

samples/MvvmSampleUwp/nuget.config

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

0 commit comments

Comments
 (0)