File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
Microsoft.Toolkit.Uwp.UI.Controls.Core/TabbedCommandBar Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ public TabbedCommandBar()
4040 DefaultStyleResourceUri = new System . Uri ( "ms-appx:///Microsoft.Toolkit.Uwp.UI.Controls.Core/Themes/Generic.xaml" ) ;
4141
4242 SelectionChanged += SelectedItemChanged ;
43+ Loaded += TabbedCommandBar_Loaded ;
4344 }
4445
4546 /// <inheritdoc/>
@@ -57,6 +58,15 @@ protected override void OnApplyTemplate()
5758 _tabbedCommandBarContentBorder = GetTemplateChild ( "PART_TabbedCommandBarContentBorder" ) as Border ;
5859 _tabChangedStoryboard = GetTemplateChild ( "TabChangedStoryboard" ) as Storyboard ;
5960
61+ // TODO: We could maybe optimize and use a lower-level Loaded event for what's hosting the MenuItems
62+ // to set SelectedItem, but then we may have to pull in another template part, so think we're OK
63+ // to do the Loaded event at the top level.
64+ }
65+
66+ private void TabbedCommandBar_Loaded ( object sender , RoutedEventArgs e )
67+ {
68+ // We need to select the item after the template is realized, otherwise the SelectedItem's
69+ // DataTemplate bindings don't properly navigate the visual tree.
6070 SelectedItem = MenuItems . FirstOrDefault ( ) ;
6171 }
6272
You can’t perform that action at this time.
0 commit comments