Skip to content

Commit fb0fc46

Browse files
authored
Fixing exception that can occur if there are no visual children when trying to find the appropriate name scope. (#1160)
Fixes #1159
1 parent 5266f35 commit fb0fc46

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

MaterialDesignThemes.Wpf/Transitions/TransitioningContentBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ private FrameworkElement GetNameScopeRoot()
131131
{
132132
//https://github.com/ButchersBoy/MaterialDesignInXamlToolkit/issues/950
133133
//Only set the NameScope if the child does not already have a TemplateNameScope set
134-
if (GetVisualChild(0) is FrameworkElement fe && NameScope.GetNameScope(fe) != null)
134+
if (VisualChildrenCount > 0 && GetVisualChild(0) is FrameworkElement fe && NameScope.GetNameScope(fe) != null)
135135
{
136136
return fe;
137137
}

0 commit comments

Comments
 (0)