Skip to content

Commit

Permalink
Fix ColorPickerButton Event Registration
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-hawker committed Oct 27, 2020
1 parent 9b561de commit 5767df4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ protected override void OnApplyTemplate()
{
if (ColorPicker != null)
{
// TODO: Unregister
ColorPicker.ColorChanged -= ColorPicker_ColorChanged;
}

base.OnApplyTemplate();
Expand All @@ -114,11 +114,7 @@ protected override void OnApplyTemplate()
}

ColorPicker.Color = SelectedColor;

this.ColorPicker.ColorChanged += (sender, args) =>
{
SelectedColor = args.NewColor;
};
ColorPicker.ColorChanged += ColorPicker_ColorChanged;

if (Flyout == null)
{
Expand All @@ -144,6 +140,11 @@ protected override void OnApplyTemplate()
}
}

private void ColorPicker_ColorChanged(Windows.UI.Xaml.Controls.ColorPicker sender, ColorChangedEventArgs args)
{
SelectedColor = args.NewColor;
}

private async void CheckeredBackgroundBorder_Loaded(object sender, RoutedEventArgs e)
{
await ColorPickerRenderingHelpers.UpdateBorderBackgroundWithCheckerAsync(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,12 @@ public static async Task<ImageBrush> BitmapToBrushAsync(
return brush;
}

/// <summary>
/// Centralizes code to create a checker brush for a <see cref="Border"/>.
/// </summary>
/// <param name="border">Border which will have its Background modified.</param>
/// <param name="color">Color to use for transparent checkerboard.</param>
/// <returns>Task</returns>
public static async Task UpdateBorderBackgroundWithCheckerAsync(Border border, Color color)
{
if (border != null)
Expand Down

0 comments on commit 5767df4

Please sign in to comment.