Return UnsetValue instead of throw exception'
As per winui docs https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.dependencyproperty.unsetvalue?view=winrt-19041#remarks
This commit is contained in:
Родитель
d509455563
Коммит
ba746674b0
|
@ -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
|
||||
|
@ -21,7 +22,7 @@ namespace Microsoft.Toolkit.Uwp.SampleApp.Converters
|
|||
Animal.Llama => Colors.Beige,
|
||||
Animal.Parrot => Colors.YellowGreen,
|
||||
Animal.Squirrel => Colors.SaddleBrown,
|
||||
_ => throw new ArgumentException("Invalid value", nameof(value))
|
||||
_ => DependencyProperty.UnsetValue
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
using System;
|
||||
using Microsoft.Toolkit.Uwp.Helpers;
|
||||
using Windows.UI;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Data;
|
||||
using Windows.UI.Xaml.Media;
|
||||
|
||||
|
@ -40,7 +41,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls.ColorPickerConverters
|
|||
}
|
||||
else
|
||||
{
|
||||
throw new ArgumentException("Invalid color value provided");
|
||||
return DependencyProperty.UnsetValue;
|
||||
}
|
||||
|
||||
// Get the value component delta
|
||||
|
@ -50,7 +51,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls.ColorPickerConverters
|
|||
}
|
||||
catch
|
||||
{
|
||||
throw new ArgumentException("Invalid parameter provided, unable to convert to integer");
|
||||
return DependencyProperty.UnsetValue;
|
||||
}
|
||||
|
||||
// Specially handle minimum (black) and maximum (white)
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
using System;
|
||||
using Microsoft.Toolkit.Uwp.Helpers;
|
||||
using Windows.UI;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Data;
|
||||
using Windows.UI.Xaml.Media;
|
||||
|
||||
|
@ -34,7 +35,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls.ColorPickerConverters
|
|||
}
|
||||
else
|
||||
{
|
||||
throw new ArgumentException("Invalid color value provided");
|
||||
return DependencyProperty.UnsetValue;
|
||||
}
|
||||
|
||||
string hexColor = color.ToHex().Replace("#", string.Empty);
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
using System;
|
||||
using Windows.UI;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Data;
|
||||
using Windows.UI.Xaml.Media;
|
||||
|
||||
|
@ -40,7 +41,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls.ColorPickerConverters
|
|||
}
|
||||
else
|
||||
{
|
||||
throw new ArgumentException("Invalid color value provided");
|
||||
return DependencyProperty.UnsetValue;
|
||||
}
|
||||
|
||||
// Get the default color when transparency is high
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
using System;
|
||||
using Windows.UI;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Data;
|
||||
using Windows.UI.Xaml.Media;
|
||||
|
||||
|
@ -33,7 +34,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Converters
|
|||
}
|
||||
else
|
||||
{
|
||||
throw new ArgumentException("Invalid color value provided");
|
||||
return DependencyProperty.UnsetValue;
|
||||
}
|
||||
|
||||
return ColorHelper.ToDisplayName(color);
|
||||
|
|
|
@ -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
|
||||
|
@ -26,7 +27,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Converters
|
|||
return task.GetResultOrDefault();
|
||||
}
|
||||
|
||||
return null;
|
||||
return DependencyProperty.UnsetValue;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
|
Загрузка…
Ссылка в новой задаче