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()
40
40
DefaultStyleResourceUri = new System . Uri ( "ms-appx:///Microsoft.Toolkit.Uwp.UI.Controls.Core/Themes/Generic.xaml" ) ;
41
41
42
42
SelectionChanged += SelectedItemChanged ;
43
+ Loaded += TabbedCommandBar_Loaded ;
43
44
}
44
45
45
46
/// <inheritdoc/>
@@ -57,6 +58,15 @@ protected override void OnApplyTemplate()
57
58
_tabbedCommandBarContentBorder = GetTemplateChild ( "PART_TabbedCommandBarContentBorder" ) as Border ;
58
59
_tabChangedStoryboard = GetTemplateChild ( "TabChangedStoryboard" ) as Storyboard ;
59
60
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.
60
70
SelectedItem = MenuItems . FirstOrDefault ( ) ;
61
71
}
62
72
You can’t perform that action at this time.
0 commit comments