diff --git a/src/Core/src/Platform/Windows/WrapperView.cs b/src/Core/src/Platform/Windows/WrapperView.cs index 0ed44ad4a4bc..37fd3c18d000 100644 --- a/src/Core/src/Platform/Windows/WrapperView.cs +++ b/src/Core/src/Platform/Windows/WrapperView.cs @@ -33,6 +33,7 @@ public WrapperView() Children.Add(_borderPath); } + long _visibilityDependencyPropertyCallbackToken; public FrameworkElement? Child { get { return _child; } @@ -41,6 +42,7 @@ internal set if (_child != null) { _child.SizeChanged -= OnChildSizeChanged; + _child.UnregisterPropertyChangedCallback(VisibilityProperty, _visibilityDependencyPropertyCallbackToken); Children.Remove(_child); } @@ -49,6 +51,7 @@ internal set _child = value; _child.SizeChanged += OnChildSizeChanged; + _visibilityDependencyPropertyCallbackToken = _child.RegisterPropertyChangedCallback(VisibilityProperty, OnChildVisibilityChanged); Children.Add(_child); } } @@ -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)