Add fallback for finding the ViewManager from View

Relates to #109
This commit is contained in:
Antony Male 2020-03-06 09:00:01 +00:00
parent 1ef62f568d
commit 699d85d1b1
1 changed files with 7 additions and 0 deletions

View File

@ -78,6 +78,13 @@ namespace Stylet.Xaml
{
var viewManager = ((FrameworkElement)d).TryFindResource(ViewManagerResourceKey) as IViewManager;
// In some very rare cases (#109), we've seen 'd' be unable to resolve the ViewManager, but it exists on the application.
// Try this as a last resort.
if (viewManager == null && Application.Current != null)
{
viewManager = Application.Current.TryFindResource(ViewManagerResourceKey) as IViewManager;
}
if (viewManager == null)
{
if (Execute.InDesignMode)