Skip to content

Commit

Permalink
Fixes #999 by using an per instance effect instead of a shared one
Browse files Browse the repository at this point in the history
  • Loading branch information
batzen committed Jan 8, 2022
1 parent 0451dec commit 0af641b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 6 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog for Fluent.Ribbon

## 9.0.2

- ### Bug fixes

- [#999](../../issues/999) - Window object not being recycled after ribbon window is closed

## 9.0.1

- ### Bug fixes
Expand Down
8 changes: 3 additions & 5 deletions Fluent.Ribbon/Controls/IconPresenter.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma warning disable 1591, WPF0012, WPF0023
// ReSharper disable once CheckNamespace
namespace Fluent
{
using System;
Expand Down Expand Up @@ -53,8 +54,7 @@ public class IconPresenter : ContentControl
public static readonly DependencyProperty CurrentIconSizeSizeProperty = DependencyProperty.Register(
nameof(CurrentIconSizeSize), typeof(Size), typeof(IconPresenter), new PropertyMetadata(new Size(16, 16)));

[ThreadStatic]
private static GrayscaleEffect? grayscaleEffect;
private GrayscaleEffect? grayscaleEffect;

static IconPresenter()
{
Expand All @@ -65,8 +65,6 @@ static IconPresenter()

public IconPresenter()
{
grayscaleEffect ??= new GrayscaleEffect();

var multiBinding = new MultiBinding { Converter = StaticConverters.ObjectToImageConverter };
multiBinding.Bindings.Add(new Binding(nameof(this.OptimalIcon)) { Source = this });
multiBinding.Bindings.Add(new Binding(nameof(this.CurrentIconSizeSize)) { Source = this });
Expand Down Expand Up @@ -144,7 +142,7 @@ private static void OnIsEnabledChanged(DependencyObject d, DependencyPropertyCha

control.Effect = newValue
? null
: grayscaleEffect;
: control.grayscaleEffect ??= new GrayscaleEffect();
control.Opacity = newValue
? 1
: 0.5;
Expand Down

0 comments on commit 0af641b

Please sign in to comment.