locked
[UWP] SplitView.PaneClosed event is available but not for PaneOpened RRS feed

  • Question

  • 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.

    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?
    Sunday, July 26, 2015 11:26 AM

Answers

  • Hello Sangadji,

    how does your SplitView open? Do you use any button or something like that?
    You can implement your logic for Pane Opened or Closed there.

    Another way to achieve it is to register on property changed event of IsPaneOpenProperty of your SplitView.

    Example:

            private long _splitViewToken;
            protected override void OnNavigatedTo(NavigationEventArgs e)
            {
                base.OnNavigatedTo(e);
    
                _splitViewToken = splitView.RegisterPropertyChangedCallback(SplitView.IsPaneOpenProperty, Callback);
    
            }
    
            protected override void OnNavigatedFrom(NavigationEventArgs e)
            {
                base.OnNavigatedFrom(e);
    
                splitView.UnregisterPropertyChangedCallback(SplitView.IsPaneOpenProperty,_splitViewToken);
            }
    
            private void Callback(DependencyObject sender, DependencyProperty dp)
            {
    //check if splitView is opened or closed. Debug.WriteLine("IsPaneOpen: "+ splitView.IsPaneOpen); }

    Hope that helps,

    George


    Sunday, July 26, 2015 1:39 PM