Skip to content

Commit

Permalink
fix shadow visibility on Windows (dotnet#10996)
Browse files Browse the repository at this point in the history
  • Loading branch information
espenrl authored and TJ Lambert committed Feb 21, 2023
1 parent 50a2ed8 commit 99f86f8
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/Core/src/Platform/Windows/WrapperView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public WrapperView()
Children.Add(_borderPath);
}

long _visibilityDependencyPropertyCallbackToken;
public FrameworkElement? Child
{
get { return _child; }
Expand All @@ -41,6 +42,7 @@ internal set
if (_child != null)
{
_child.SizeChanged -= OnChildSizeChanged;
_child.UnregisterPropertyChangedCallback(VisibilityProperty, _visibilityDependencyPropertyCallbackToken);
Children.Remove(_child);
}

Expand All @@ -49,6 +51,7 @@ internal set

_child = value;
_child.SizeChanged += OnChildSizeChanged;
_visibilityDependencyPropertyCallbackToken = _child.RegisterPropertyChangedCallback(VisibilityProperty, OnChildVisibilityChanged);
Children.Add(_child);
}
}
Expand Down Expand Up @@ -142,6 +145,16 @@ void OnChildSizeChanged(object sender, SizeChangedEventArgs e)
UpdateShadow();
}

void OnChildVisibilityChanged(DependencyObject sender, DependencyProperty dp)
{
// OnChildSizeChanged does not fire for Visibility changes to child
if (sender is FrameworkElement child && _shadowCanvas.Children.Count > 0)
{
var shadowHost = _shadowCanvas.Children[0];
shadowHost.Visibility = child.Visibility;
}
}

void DisposeShadow()
{
if (_shadowCanvas == null)
Expand Down

0 comments on commit 99f86f8

Please sign in to comment.