Skip to content

Commit 482f574

Browse files
committed
Fixed timer not stopping
1 parent a985dce commit 482f574

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

MaterialDesignThemes.Wpf/PaletteHelper.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ private static bool ReplaceEntry(object entryName, object newValue, ResourceDict
134134
{
135135
if (animate) //Fade animation is enabled
136136
{
137-
bool isfinished = false;
137+
System.Windows.Threading.DispatcherTimer dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
138138
var brush = new SolidColorBrush();
139139
ColorAnimation animation = new ColorAnimation()
140140
{
@@ -144,15 +144,11 @@ private static bool ReplaceEntry(object entryName, object newValue, ResourceDict
144144
};
145145
animation.Completed += (s,e) =>
146146
{
147-
isfinished = true;
147+
dispatcherTimer.Stop();
148148
};
149149
brush.BeginAnimation(SolidColorBrush.ColorProperty, animation); //Begin the animation
150-
System.Windows.Threading.DispatcherTimer dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
151-
dispatcherTimer.Tick += (sender, e) =>
152-
{
153-
if (!isfinished)
154-
parentDictionary[entryName] = brush;
155-
};
150+
151+
dispatcherTimer.Tick += (sender, e) => parentDictionary[entryName] = brush;
156152
dispatcherTimer.Interval = new TimeSpan(0,0,0,0,DURATION_MS / 60);//60 can be replaced with the animation frame rate.
157153
dispatcherTimer.Start();
158154

0 commit comments

Comments
 (0)