Skip to content

Commit f17770d

Browse files
committed
fix: Indicate selected item in NavigationView
- Fixes #4794 - ensures the pre-selected NavigationView item is indicated after loading
1 parent c3bb057 commit f17770d

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

src/SamplesApp/SamplesApp.Shared/App.xaml.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,10 @@ override async void OnActivated(IActivatedEventArgs e)
210210
$"PreviousState - {e.PreviousExecutionState}, " +
211211
$"Uri - {protocolActivatedEventArgs.Uri}",
212212
"Application activated via protocol");
213+
#if !__SKIA__
214+
// TODO: Re-enable when #4810 is closed
213215
await dlg.ShowAsync();
216+
#endif
214217
}
215218
}
216219

@@ -254,7 +257,10 @@ private async void DisplayLaunchArguments(LaunchActivatedEventArgs launchActivat
254257
if (!string.IsNullOrEmpty(launchActivatedEventArgs.Arguments))
255258
{
256259
var dlg = new MessageDialog(launchActivatedEventArgs.Arguments, "Launch arguments");
260+
#if !__SKIA__
261+
// TODO: Re-enable when #4810 is closed
257262
await dlg.ShowAsync();
263+
#endif
258264
}
259265
}
260266

src/SamplesApp/UITests.Shared/Microsoft_UI_Xaml_Controls/NavigationViewTests/NavigationViewBasicPage.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<Grid>
1313
<mux:NavigationView x:Name="NavigationViewControl">
1414
<mux:NavigationView.MenuItems>
15-
<mux:NavigationViewItem Content="A" x:Name="A" />
15+
<mux:NavigationViewItem IsSelected="True" Content="A" x:Name="A" />
1616
<mux:NavigationViewItem Content="B" x:Name="B" />
1717
<mux:NavigationViewItem Content="C" x:Name="C" />
1818
</mux:NavigationView.MenuItems>

src/Uno.UI/Microsoft/UI/Xaml/Controls/NavigationView/NavigationView.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1375,8 +1375,12 @@ int GetChildDepth(NavigationViewRepeaterPosition position, NavigationViewItemBas
13751375
});
13761376
}
13771377

1378+
#if IS_UNO
13781379
// TODO: Uno specific - remove when #4689 is fixed
1380+
// This ensures the item is properly initialized and the selected item is displayed
13791381
nvibImpl.Reinitialize();
1382+
AnimateSelectionChanged(SelectedItem);
1383+
#endif
13801384
}
13811385
}
13821386

@@ -5804,7 +5808,7 @@ private bool IsTopLevelItem(NavigationViewItemBase nvib)
58045808
return IsRootItemsRepeater(GetParentItemsRepeaterForContainer(nvib));
58055809
}
58065810

5807-
#region Uno specific
5811+
#region Uno specific
58085812

58095813
//TODO: Uno specific - remove when #4689 is fixed
58105814

@@ -5824,6 +5828,6 @@ private void SetHeaderContentMinHeight(double minHeight)
58245828
}
58255829
}
58265830

5827-
#endregion
5831+
#endregion
58285832
}
58295833
}

src/Uno.UI/UI/Xaml/UIElement.Layout.netstd.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ public void Arrange(Rect finalRect)
115115
{
116116
LayoutInformation.SetLayoutSlot(this, finalRect);
117117
HideVisual();
118+
_isArrangeValid = true;
118119
return;
119120
}
120121

0 commit comments

Comments
 (0)