@@ -96,11 +96,14 @@ public MainWindow()
9696 DataContext = new MainWindowViewModel ( ) ;
9797 InitializeComponent ( ) ;
9898 SetupTitleBar ( ) ;
99+ SetupResponsiveRail ( ) ;
99100
100101 RestoreGeometry ( ) ;
101102
102103 KeyDown += Window_KeyDown ;
103104 ViewModel . CurrentPageChanged += OnCurrentPageChanged ;
105+ // Title-bar back button: visible whenever there's somewhere to go back to (mirrors WinUI's TitleBar.IsBackButtonVisible).
106+ ViewModel . CanGoBackChanged += ( _ , canGoBack ) => BackButton . IsVisible = canGoBack ;
104107 ViewModel . PropertyChanged += OnViewModelPropertyChanged ;
105108 UpdateOperationsPanelRow ( ) ;
106109
@@ -216,6 +219,9 @@ private void Window_KeyDown(object? sender, KeyEventArgs e)
216219
217220 private void OnCurrentPageChanged ( object ? sender , PageType pageType )
218221 {
222+ // Like WinUI's NavigationView: picking a page collapses the sliding flyout back to the rail.
223+ ViewModel . Sidebar . IsPaneOpen = false ;
224+
219225 if ( ! _focusSidebarSelectionOnNextPageChange )
220226 return ;
221227
@@ -227,6 +233,8 @@ private void OnCurrentPageChanged(object? sender, PageType pageType)
227233 } , DispatcherPriority . Background ) ;
228234 }
229235
236+ private void BackButton_Click ( object ? sender , RoutedEventArgs e ) => ViewModel . NavigateBack ( ) ;
237+
230238 private void OnViewModelPropertyChanged ( object ? sender , System . ComponentModel . PropertyChangedEventArgs e )
231239 {
232240 if ( e . PropertyName is nameof ( MainWindowViewModel . OperationsPanelExpanded )
@@ -240,10 +248,10 @@ or nameof(MainWindowViewModel.OperationsPanelVisible))
240248 // user's chosen size across collapse/expand.
241249 private void UpdateOperationsPanelRow ( )
242250 {
243- if ( MainContentGrid . RowDefinitions . Count < 3 )
251+ if ( ContentRoot . RowDefinitions . Count < 3 )
244252 return ;
245253
246- RowDefinition row = MainContentGrid . RowDefinitions [ 2 ] ;
254+ RowDefinition row = ContentRoot . RowDefinitions [ 2 ] ;
247255 if ( ViewModel . OperationsPanelVisible && ViewModel . OperationsPanelExpanded )
248256 {
249257 row . MinHeight = 80 ;
@@ -258,6 +266,21 @@ private void UpdateOperationsPanelRow()
258266 }
259267 }
260268
269+ // ─── Navigation rail (responsive) ─────────────────────────────────────────
270+ // The always-visible icon rail shows on roomy windows and collapses below 800px so narrow
271+ // windows give the content full width (the hamburger + sliding flyout still provide nav).
272+ private void SetupResponsiveRail ( )
273+ => MainContentRoot . GetObservable ( BoundsProperty )
274+ . Subscribe ( b =>
275+ {
276+ if ( b . Width <= 0 ) return ;
277+ NavRail . IsVisible = b . Width >= 800 ;
278+ } ) ;
279+
280+ // Light-dismiss: clicking outside the open flyout closes it (no darkening — the layer is transparent).
281+ private void FlyoutDismiss_PointerPressed ( object ? sender , PointerPressedEventArgs e )
282+ => ViewModel . Sidebar . IsPaneOpen = false ;
283+
261284 private void SetupTitleBar ( )
262285 {
263286 if ( OperatingSystem . IsMacOS ( ) )
@@ -278,8 +301,8 @@ private void SetupTitleBar()
278301 {
279302 TitleBarGrid . ClearValue ( HeightProperty ) ;
280303 TitleBarGrid . Height = 44 ;
281- MainContentGrid . ClearValue ( MarginProperty ) ;
282- MainContentGrid . Margin = new Thickness ( 0 , 44 , 0 , 0 ) ;
304+ MainContentRoot . ClearValue ( MarginProperty ) ;
305+ MainContentRoot . Margin = new Thickness ( 0 , 44 , 0 , 0 ) ;
283306 HamburgerPanel . Margin = new Thickness ( 10 , 0 , 8 , 0 ) ;
284307 }
285308 else
@@ -288,7 +311,7 @@ private void SetupTitleBar()
288311 {
289312 RelativeSource = new RelativeSource ( RelativeSourceMode . FindAncestor ) { AncestorType = typeof ( Window ) } ,
290313 } ) ;
291- MainContentGrid . Bind ( MarginProperty , new Binding ( "WindowDecorationMargin" )
314+ MainContentRoot . Bind ( MarginProperty , new Binding ( "WindowDecorationMargin" )
292315 {
293316 RelativeSource = new RelativeSource ( RelativeSourceMode . FindAncestor ) { AncestorType = typeof ( Window ) } ,
294317 } ) ;
@@ -311,7 +334,7 @@ private void SetupTitleBar()
311334 TitleBarGrid . Height = 44 ;
312335 HamburgerPanel . Margin = new Thickness ( 10 , 0 , 8 , 0 ) ;
313336 WindowButtons . IsVisible = true ;
314- MainContentGrid . Margin = new Thickness ( 0 , 44 , 0 , 0 ) ;
337+ MainContentRoot . Margin = new Thickness ( 0 , 44 , 0 , 0 ) ;
315338 this . GetObservable ( WindowStateProperty ) . Subscribe ( state =>
316339 {
317340 UpdateMaximizeButtonState ( state == WindowState . Maximized ) ;
@@ -328,7 +351,7 @@ private void SetupTitleBar()
328351 TitleBarGrid . Height = 44 ;
329352 HamburgerPanel . Margin = new Thickness ( 10 , 0 , 8 , 0 ) ;
330353 WindowButtons . IsVisible = ! useNativeDecorations ;
331- MainContentGrid . Margin = new Thickness ( 0 , 44 , 0 , 0 ) ;
354+ MainContentRoot . Margin = new Thickness ( 0 , 44 , 0 , 0 ) ;
332355 // Keep maximize icon in sync with window state
333356 this . GetObservable ( WindowStateProperty ) . Subscribe ( state =>
334357 {
0 commit comments