Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System;
using Microsoft.Toolkit.Uwp.SampleApp.Enums;
using Windows.UI;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Data;

namespace Microsoft.Toolkit.Uwp.SampleApp.Converters
Expand All @@ -21,7 +22,7 @@ public object Convert(object value, Type targetType, object parameter, string la
Animal.Llama => Colors.Beige,
Animal.Parrot => Colors.YellowGreen,
Animal.Squirrel => Colors.SaddleBrown,
_ => throw new ArgumentException("Invalid value", nameof(value))
_ => DependencyProperty.UnsetValue
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public sealed class AnimalToColorConverter : IValueConverter
Animal.Bunny => Colors.Green,
Animal.Parrot => Colors.YellowGreen,
Animal.Squirrel => Colors.SaddleBrown,
_ => throw new ArgumentException("Invalid value", nameof(value))
_ => DependencyProperty.UnsetValue
};
}

Expand Down
3 changes: 2 additions & 1 deletion Microsoft.Toolkit.Uwp.UI/Converters/TaskResultConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

using System;
using System.Threading.Tasks;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Data;

namespace Microsoft.Toolkit.Uwp.UI.Converters
Expand All @@ -26,7 +27,7 @@ public object Convert(object value, Type targetType, object parameter, string la
return task.GetResultOrDefault();
}

return null;
return DependencyProperty.UnsetValue;
}

/// <inheritdoc/>
Expand Down
2 changes: 1 addition & 1 deletion Microsoft.Toolkit.Uwp.UI/Extensions/UIElementExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static class UIElementExtensions
"ClipToBounds",
typeof(bool),
typeof(UIElementExtensions),
new PropertyMetadata(DependencyProperty.UnsetValue, OnClipToBoundsPropertyChanged));
new PropertyMetadata(null, OnClipToBoundsPropertyChanged));

/// <summary>
/// Gets the value of <see cref="ClipToBoundsProperty"/>
Expand Down
14 changes: 11 additions & 3 deletions UnitTests/UnitTests.UWP/Converters/Test_TaskResultConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Microsoft.Toolkit.Uwp.UI.Converters;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.VisualStudio.TestTools.UnitTesting.AppContainer;
using Windows.UI.Xaml;

namespace UnitTests.Converters
{
Expand Down Expand Up @@ -70,12 +71,19 @@ public void Test_TaskResultConverter_Instance_String()

[TestCategory("Converters")]
[UITestMethod]
public void Test_TaskResultConverter_Instance_Null()
public void Test_TaskResultConverter_Instance_UnsetValue()
{
var converter = new TaskResultConverter();

Assert.AreEqual(null, converter.Convert(null, null, null, null));
Assert.AreEqual(null, converter.Convert("Hello world", null, null, null));
Assert.AreEqual(DependencyProperty.UnsetValue, converter.Convert(null, null, null, null));
Assert.AreEqual(DependencyProperty.UnsetValue, converter.Convert("Hello world", null, null, null));
}

[TestCategory("Converters")]
[UITestMethod]
public void Test_TaskResultConverter_Instance_Null()
{
var converter = new TaskResultConverter();

var cts = new CancellationTokenSource();

Expand Down