SplitView.PaneClosed事件可用,但不适用于PaneOpened。

3
根据 https://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.splitview.paneclosed.aspx 中的说明,SplitView控件没有PaneOpened事件,只有存在于SplitView控件中的PaneClosed事件。
我在SplitView面板中放置了一个Button控件,需要根据面板是打开还是关闭来更改其大小。因此,我的计划是在PaneOpened事件中放置一段代码,将按钮大小更改为更宽,然后在PaneClosed事件中将其恢复到小尺寸。但似乎没有PaneOpened事件。
我还有其他方法可以实现这个目标吗?
1个回答

9

感谢UWP中的新功能RegisterPropertyChangedCallback,现在您可以监视任何DependencyProperty(包括本机属性)的属性更改事件。

public SplitViewPage()
{
    this.InitializeComponent();

    this.splitView.RegisterPropertyChangedCallback(SplitView.IsPaneOpenProperty, IsPaneOpenPropertyChanged);
}

private void IsPaneOpenPropertyChanged(DependencyObject sender, DependencyProperty dp)
{
    // put your logic here
}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接