3

根据https://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.splitview.paneclosed.aspx,SplitView控件没有 PaneOpened 事件,只有 PaneClosed 事件存在的 SplitView 控件。

我在 SplitView 窗格中有一个 Button 控件,该控件需要根据窗格是打开还是关闭来更改大小。所以我的计划是我将放置一段代码,在 PaneOpened 事件中将按钮大小更改为更宽,并在 PaneClosed 事件中将其恢复为小尺寸。但似乎没有 PaneOpened 事件。

我可以通过其他任何方式实现这一目标吗?

4

1 回答 1

9

多亏了 UWP 中新的RegisterPropertyChangedCallback,您现在可以监视 anyDependencyProperty的属性更改事件,包括本机事件。

public SplitViewPage()
{
    this.InitializeComponent();

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

private void IsPaneOpenPropertyChanged(DependencyObject sender, DependencyProperty dp)
{
    // put your logic here
}
于 2015-08-04T09:46:58.113 回答