Update TransitioningContentControl.cs

Fix. Null Exception.
When using "ContextMenu" with "TransitioningContentControl" and when "MenuItem" call "Application Shutdown", then the application throws a null exception, because "Application.Current" is null and fadeout animation call "ResourceHelper.GetResource".
This commit is contained in:
xsnakes 2020-09-07 16:29:46 +03:00 committed by GitHub
parent fc84f806dd
commit cf9b17f19d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -49,7 +49,14 @@ namespace HandyControl.Controls
{
if (Visibility != Visibility.Visible || _contentPresenter == null) return;
(TransitionStoryboard ?? ResourceHelper.GetResource<Storyboard>($"{TransitionMode.ToString()}Transition"))?.Begin(_contentPresenter);
if (TransitionStoryboard != null)
{
TransitionStoryboard.Begin(_contentPresenter);
}
else if (Application.Current != null)
{
ResourceHelper.GetResource<Storyboard>($"{TransitionMode.ToString()}Transition")?.Begin(_contentPresenter);
}
}
public override void OnApplyTemplate()
@ -73,4 +80,4 @@ namespace HandyControl.Controls
}
}
}
}
}