-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: ColorPicker Binding failed (#579)
* fix ColorPicker Binding failed * Apply suggestions from code review * Update components/ColorPicker/src/Converters/NullToTransparentConverter.cs --------- Co-authored-by: Arlo <[email protected]> Co-authored-by: Michael Hawker MSFT (XAML Llama) <[email protected]>
- Loading branch information
1 parent
2c0f9b3
commit 97e0d39
Showing
2 changed files
with
25 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
components/ColorPicker/src/Converters/NullToTransparentConverter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
namespace CommunityToolkit.WinUI.Controls; | ||
|
||
/// <summary> | ||
/// Value converter that converts null values to Transparent. | ||
/// </summary> | ||
public partial class NullToTransparentConverter : IValueConverter | ||
{ | ||
/// <inheritdoc/> | ||
public object Convert(object value, Type targetType, object parameter, string language) => value; | ||
|
||
/// <inheritdoc/> | ||
public object ConvertBack(object? value, Type targetType, object parameter, string language) => value ?? | ||
#if WINUI2 | ||
Windows.UI.Colors.Transparent; | ||
#else | ||
Microsoft.UI.Colors.Transparent; | ||
#endif | ||
} |