Windows.UI.Xaml.UIElement
而非System.Windows.UIElement
没有此事件:
public event DependencyPropertyChangedEventHandler IsVisibleChanged
所以有两个问题:
(在代码隐藏(.xaml.cs)中,对于每个IsVisibleChanged
事件或每个Canvas
调整大小事件,我需要重新排列Canvas
个孩子。)
答案 0 :(得分:2)
您可以使用RegisterPropertyChangedCallback
为Visibility
属性注册更改回调:
element.RegisterPropertyChangedCallback(UIElement.VisibilityProperty, VisibilityChanged);
...
private void VisibilityChanged(DependencyObject sender, DependencyProperty property)
{
var visibility = ((UIElement)sender).Visibility;
...
}