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 @@ -44,6 +44,7 @@
<localconverters:ColorToColorShadeConverter x:Key="ColorToColorShadeConverter" />
<converters:ColorToDisplayNameConverter x:Key="ColorToDisplayNameConverter" />
<localconverters:ColorToHexConverter x:Key="ColorToHexConverter" />
<localconverters:ColorToSelectedValueConverter x:Key="ColorToSelectedValueConverter" />

<Style x:Key="InputTextBoxStyle"
TargetType="TextBox">
Expand Down Expand Up @@ -157,7 +158,7 @@
Padding="0"
ItemContainerStyle="{StaticResource PaletteGridViewItemStyle}"
ItemsSource="{TemplateBinding CustomPaletteColors}"
SelectedValue="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Color, Mode=TwoWay}"
SelectedValue="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Color, Mode=TwoWay, Converter={StaticResource ColorToSelectedValueConverter}}"
SelectionMode="Single"
Tag="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Color, Mode=OneWay}">
<GridView.ItemsPanel>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// 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.

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

namespace Microsoft.Toolkit.Uwp.UI.Controls.ColorPickerConverters
{
/// <summary>
/// Ignores null target values for TwoWay binding.
/// </summary>
public class ColorToSelectedValueConverter : IValueConverter
{
/// <inheritdoc/>
public object Convert(
object value,
Type targetType,
object parameter,
string language)
{
return value;
}

/// <inheritdoc/>
public object ConvertBack(
object value,
Type targetType,
object parameter,
string language)
{
return value ?? DependencyProperty.UnsetValue;
}
}
}