@@ -188,23 +188,23 @@ public bool IsRightPaneVisible
188188 if ( value != _IsRightPaneVisible )
189189 {
190190 _IsRightPaneVisible = value ;
191- if ( ! _IsRightPaneVisible )
192- {
193- ActivePane = GetPane ( 0 ) ;
194- Pane_ContentChanged ( null ! , null ! ) ;
195- }
196-
197- NotifyPropertyChanged ( nameof ( IsRightPaneVisible ) ) ;
198- NotifyPropertyChanged ( nameof ( IsMultiPaneActive ) ) ;
199191
200192 if ( value )
201193 {
202194 AddPane ( ) ;
203195 }
204196 else
205197 {
206- RemovePane ( ( RootGrid . Children . Count - 1 ) / 2 ) ;
198+ if ( GetPaneCount ( ) != 1 )
199+ {
200+ ActivePane = GetPane ( 0 ) ;
201+ Pane_ContentChanged ( null ! , null ! ) ;
202+ RemovePane ( ( RootGrid . Children . Count - 1 ) / 2 ) ;
203+ }
207204 }
205+
206+ NotifyPropertyChanged ( nameof ( IsRightPaneVisible ) ) ;
207+ NotifyPropertyChanged ( nameof ( IsMultiPaneActive ) ) ;
208208 }
209209 }
210210 }
@@ -272,10 +272,12 @@ public void OpenSecondaryPane(string path)
272272 ActivePane = GetPane ( 1 ) ;
273273 }
274274
275- public void CloseSecondaryPane ( )
275+ public void CloseActivePane ( )
276276 {
277- // Remove right pane within this property's setter
278- IsRightPaneVisible = false ;
277+ if ( ActivePane == ( IShellPage ) GetPane ( 0 ) )
278+ RemovePane ( 0 ) ;
279+ else
280+ IsRightPaneVisible = false ;
279281
280282 GetPane ( 0 ) ? . Focus ( FocusState . Programmatic ) ;
281283 SetShadow ( ) ;
@@ -346,7 +348,6 @@ private void AddPane()
346348 NotifyPropertyChanged ( nameof ( IsMultiPaneActive ) ) ;
347349 }
348350
349- // TODO: Shift column index for when to close left pane
350351 private void RemovePane ( int index = - 1 )
351352 {
352353 if ( index is - 1 )
@@ -355,14 +356,35 @@ private void RemovePane(int index = -1)
355356 // Get proper position of sizer that resides with the pane that is wanted to be removed
356357 var childIndex = index * 2 - 1 ;
357358 childIndex = childIndex >= 0 ? childIndex : 0 ;
359+ if ( childIndex >= RootGrid . Children . Count )
360+ return ;
361+
362+ if ( childIndex == 0 )
363+ {
364+ var wasMultiPaneActive = IsMultiPaneActive ;
358365
359- // Remove sizer and pane from children
360- RootGrid . Children . RemoveAt ( childIndex ) ;
361- RootGrid . Children . RemoveAt ( childIndex ) ;
366+ // Remove sizer and pane
367+ RootGrid . Children . RemoveAt ( 0 ) ;
368+ RootGrid . ColumnDefinitions . RemoveAt ( 0 ) ;
362369
363- // Remove sizer and pane from column definitions
364- RootGrid . ColumnDefinitions . RemoveAt ( childIndex ) ;
365- RootGrid . ColumnDefinitions . RemoveAt ( childIndex ) ;
370+ if ( wasMultiPaneActive )
371+ {
372+ RootGrid . Children . RemoveAt ( 0 ) ;
373+ RootGrid . ColumnDefinitions . RemoveAt ( 0 ) ;
374+ RootGrid . Children [ 0 ] . SetValue ( Grid . ColumnProperty , 0 ) ;
375+ _NavParamsLeft = new ( ) { NavPath = GetPane ( 0 ) ? . TabBarItemParameter ? . NavigationParameter as string ?? string . Empty } ;
376+ IsRightPaneVisible = false ;
377+ ActivePane = GetPane ( 0 ) ;
378+ }
379+ }
380+ else
381+ {
382+ // Remove sizer and pane
383+ RootGrid . Children . RemoveAt ( childIndex ) ;
384+ RootGrid . Children . RemoveAt ( childIndex ) ;
385+ RootGrid . ColumnDefinitions . RemoveAt ( childIndex ) ;
386+ RootGrid . ColumnDefinitions . RemoveAt ( childIndex ) ;
387+ }
366388
367389 NotifyPropertyChanged ( nameof ( IsMultiPaneActive ) ) ;
368390 }
0 commit comments