Skip to content

Commit 0138b7a

Browse files
committed
Fix a crash in the async relay command page
1 parent fed6414 commit 0138b7a

File tree

4 files changed

+39
-4
lines changed

4 files changed

+39
-4
lines changed

samples/MvvmSample.Core/MvvmSample.Core.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
</Content>
4646
</ItemGroup>
4747
<ItemGroup>
48-
<PackageReference Include="CommunityToolkit.Mvvm" Version="7.0.3" />
48+
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.0.0-preview2" />
4949
<PackageReference Include="Nito.AsyncEx.Coordination" Version="5.1.2" />
5050
<PackageReference Include="Refit" Version="6.3.2" />
5151
</ItemGroup>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using System;
6+
using System.Threading.Tasks;
7+
using Windows.UI.Xaml.Data;
8+
9+
namespace Microsoft.Toolkit.Uwp.UI.Converters
10+
{
11+
/// <summary>
12+
/// Custom version of the converter from the Toolkit, with a bug fix.
13+
/// This should be moved over to the Toolkit in the next release.
14+
/// </summary>
15+
public sealed class TaskResultConverter2 : IValueConverter
16+
{
17+
/// <inheritdoc/>
18+
public object Convert(object value, Type targetType, object parameter, string language)
19+
{
20+
if (value is Task task)
21+
{
22+
return task.GetResultOrDefault();
23+
}
24+
25+
return null;
26+
}
27+
28+
/// <inheritdoc/>
29+
public object ConvertBack(object value, Type targetType, object parameter, string language)
30+
{
31+
throw new NotImplementedException();
32+
}
33+
}
34+
}

samples/MvvmSampleUwp/MvvmSampleUwp.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,13 @@
120120
<Compile Include="App.xaml.cs">
121121
<DependentUpon>App.xaml</DependentUpon>
122122
</Compile>
123-
<Compile Include="Controls\DocumentationBlock.cs" >
123+
<Compile Include="Controls\DocumentationBlock.cs">
124124
<DependentUpon>DocumentationBlock.xaml</DependentUpon>
125125
</Compile>
126-
<Compile Include="Controls\InteractiveSample.cs" >
126+
<Compile Include="Controls\InteractiveSample.cs">
127127
<DependentUpon>InteractiveSample.xaml</DependentUpon>
128128
</Compile>
129+
<Compile Include="Converters\TaskResultConverter.cs" />
129130
<Compile Include="Helpers\TitleBarHelper.cs" />
130131
<Compile Include="Properties\AssemblyInfo.cs" />
131132
<Compile Include="Services\FileService.cs" />

samples/MvvmSampleUwp/Views/AsyncRelayCommandPage.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
</core:EventTriggerBehavior>
2222
</interactivity:Interaction.Behaviors>
2323
<Page.Resources>
24-
<converters:TaskResultConverter x:Key="TaskResultConverter" />
24+
<converters:TaskResultConverter2 x:Key="TaskResultConverter" />
2525
</Page.Resources>
2626

2727
<ScrollViewer Padding="{StaticResource DocumentationPageContentPadding}" CanContentRenderOutsideBounds="True">

0 commit comments

Comments
 (0)