Skip to content

Commit 1dac6da

Browse files
committed
Merge branch 'main' into winui
# Conflicts: # CommunityToolkit.WinUI.UI.Controls.Core/TabbedCommandBar/TabbedCommandBar.cs # CommunityToolkit.WinUI.UI.Controls.Core/TabbedCommandBar/TabbedCommandBar.xaml # CommunityToolkit.WinUI.UI.Controls.Core/TabbedCommandBar/TabbedCommandBarItem.xaml
2 parents 405b8c0 + e4e06cb commit 1dac6da

File tree

5 files changed

+460
-390
lines changed

5 files changed

+460
-390
lines changed

CommunityToolkit.WinUI.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"/>

CommunityToolkit.WinUI.UI.Controls.Core/TabbedCommandBar/TabbedCommandBar.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
using Microsoft.UI.Xaml;
88
using Microsoft.UI.Xaml.Controls;
99
using Microsoft.UI.Xaml.Markup;
10-
using Microsoft.UI.Xaml.Media;
1110
using Microsoft.UI.Xaml.Media.Animation;
11+
using NavigationView = Microsoft.UI.Xaml.Controls.NavigationView;
12+
using NavigationViewSelectionChangedEventArgs = Microsoft.UI.Xaml.Controls.NavigationViewSelectionChangedEventArgs;
1213

1314
namespace CommunityToolkit.WinUI.UI.Controls
1415
{
@@ -37,11 +38,13 @@ public class TabbedCommandBar : NavigationView
3738
public TabbedCommandBar()
3839
{
3940
DefaultStyleKey = typeof(TabbedCommandBar);
41+
DefaultStyleResourceUri = new System.Uri("ms-appx:///Microsoft.Toolkit.Uwp.UI.Controls.Core/Themes/Generic.xaml");
4042

4143
// WinUI3 workaround for https://github.com/microsoft/microsoft-ui-xaml/issues/3502
4244
this.DefaultStyleResourceUri = new Uri("ms-appx:///CommunityToolkit.WinUI.UI.Controls.Core/Themes/Generic.xaml");
4345

4446
SelectionChanged += SelectedItemChanged;
47+
Loaded += TabbedCommandBar_Loaded;
4548
}
4649

4750
/// <inheritdoc/>
@@ -59,6 +62,15 @@ protected override void OnApplyTemplate()
5962
_tabbedCommandBarContentBorder = GetTemplateChild("PART_TabbedCommandBarContentBorder") as Border;
6063
_tabChangedStoryboard = GetTemplateChild("TabChangedStoryboard") as Storyboard;
6164

65+
// TODO: We could maybe optimize and use a lower-level Loaded event for what's hosting the MenuItems
66+
// to set SelectedItem, but then we may have to pull in another template part, so think we're OK
67+
// to do the Loaded event at the top level.
68+
}
69+
70+
private void TabbedCommandBar_Loaded(object sender, RoutedEventArgs e)
71+
{
72+
// We need to select the item after the template is realized, otherwise the SelectedItem's
73+
// DataTemplate bindings don't properly navigate the visual tree.
6274
SelectedItem = MenuItems.FirstOrDefault();
6375
}
6476

0 commit comments

Comments
 (0)