本文介绍了SplitView.PaneClosed 事件可用,但不适用于 PaneOpened的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

According to the https://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.splitview.paneclosed.aspx there is no PaneOpened event for the SplitView control, only PaneClosed event for the SplitView control that exists.

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

I have a Button control inside a SplitView pane that needs to change in size according whether the pane is opened or closed. So my plan is I will place a piece of code that will change the button size wider in the PaneOpened event, and restore it back to the small size in PaneClosed event. But it seems there is no PaneOpened event.

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

Any other way that I can achieve this?

推荐答案

感谢新的 RegisterPropertyChangedCallback 在 UWP 中,您现在可以监视任何 DependencyProperty 的属性更改事件,包括原生的.

Thanks to the new RegisterPropertyChangedCallback in UWP, you can now monitor property change events of any DependencyProperty, including native ones.

public SplitViewPage()
{
    this.InitializeComponent();

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

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

这篇关于SplitView.PaneClosed 事件可用,但不适用于 PaneOpened的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 23:22