Skip to content

Commit 4e39650

Browse files
authored
Merge branch 'main' into anyCpuBuilds
2 parents cd3fe35 + e4e06cb commit 4e39650

File tree

5 files changed

+454
-382
lines changed

5 files changed

+454
-382
lines changed

Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TabbedCommandBar/TabbedCommandBar.bind

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414
<RowDefinition/>
1515
</Grid.RowDefinitions>
1616

17-
<controls:TabbedCommandBar>
17+
<controls:TabbedCommandBar> <!-- IsBackButtonVisible="Visible" -->
18+
<controls:TabbedCommandBar.AutoSuggestBox>
19+
<AutoSuggestBox QueryIcon="Find" AutomationProperties.Name="Search" />
20+
</controls:TabbedCommandBar.AutoSuggestBox>
1821
<controls:TabbedCommandBar.PaneFooter>
1922
<CommandBar Background="Transparent" DefaultLabelPosition="Right">
2023
<AppBarButton Label="Share" Icon="Share"/>

Microsoft.Toolkit.Uwp.UI.Controls.Core/TabbedCommandBar/TabbedCommandBar.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
using Windows.UI.Xaml;
77
using Windows.UI.Xaml.Controls;
88
using Windows.UI.Xaml.Markup;
9-
using Windows.UI.Xaml.Media;
109
using Windows.UI.Xaml.Media.Animation;
10+
using NavigationView = Microsoft.UI.Xaml.Controls.NavigationView;
11+
using NavigationViewSelectionChangedEventArgs = Microsoft.UI.Xaml.Controls.NavigationViewSelectionChangedEventArgs;
1112

1213
namespace Microsoft.Toolkit.Uwp.UI.Controls
1314
{
@@ -36,8 +37,10 @@ public class TabbedCommandBar : NavigationView
3637
public TabbedCommandBar()
3738
{
3839
DefaultStyleKey = typeof(TabbedCommandBar);
40+
DefaultStyleResourceUri = new System.Uri("ms-appx:///Microsoft.Toolkit.Uwp.UI.Controls.Core/Themes/Generic.xaml");
3941

4042
SelectionChanged += SelectedItemChanged;
43+
Loaded += TabbedCommandBar_Loaded;
4144
}
4245

4346
/// <inheritdoc/>
@@ -55,6 +58,15 @@ protected override void OnApplyTemplate()
5558
_tabbedCommandBarContentBorder = GetTemplateChild("PART_TabbedCommandBarContentBorder") as Border;
5659
_tabChangedStoryboard = GetTemplateChild("TabChangedStoryboard") as Storyboard;
5760

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.
5870
SelectedItem = MenuItems.FirstOrDefault();
5971
}
6072

0 commit comments

Comments
 (0)