Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Kinnara authored Nov 20, 2023
1 parent a0a3cd4 commit e5c8538
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 11 deletions.
2 changes: 1 addition & 1 deletion ModernWpf.Controls/CommandBar/CommandBar.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
Background="{TemplateBinding Background}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" MinWidth="{DynamicResource AppBarMoreButtonColumnMinWidth}"/>
</Grid.ColumnDefinitions>
<Grid>
<Grid.ColumnDefinitions>
Expand Down
20 changes: 18 additions & 2 deletions ModernWpf.Controls/CommandBarFlyout/CommandBarFlyout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,23 @@ public CommandBarFlyout()
{
InternalPopup.SuppressFadeAnimation = true;

if (ShowMode == FlyoutShowMode.Standard)
if (m_commandBar is { } commandBar)
{
m_commandBar.IsOpen = true;
if (ShowMode == FlyoutShowMode.Standard)
{
m_commandBar.IsOpen = true;
}

// When CommandBarFlyout is in AlwaysOpen state, don't show the overflow button
if (AlwaysExpanded)
{
commandBar.IsOpen = true;
commandBar.OverflowButtonVisibility = CommandBarOverflowButtonVisibility.Collapsed;
}
else
{
commandBar.OverflowButtonVisibility = CommandBarOverflowButtonVisibility.Auto;
}
}
};

Expand Down Expand Up @@ -183,6 +197,8 @@ public CommandBarFlyout()
};
}

public bool AlwaysExpanded { get; set; }

public ObservableCollection<ICommandBarElement> PrimaryCommands { get; }

public ObservableCollection<ICommandBarElement> SecondaryCommands { get; }
Expand Down
2 changes: 1 addition & 1 deletion ModernWpf.Controls/CommandBarFlyout/CommandBarFlyout.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" MinWidth="3"/>
</Grid.ColumnDefinitions>
<primitives:CommandBarPanel
x:Name="PART_ToolBarPanel"
Expand Down
1 change: 1 addition & 0 deletions ModernWpf/Styles/CommandBar.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<sys:Double x:Key="AppBarThemeMinHeight">64</sys:Double>
<sys:Double x:Key="AppBarThemeCompactHeight">48</sys:Double>
<Thickness x:Key="AppBarEllipsisButtonInnerBorderMargin">2,6,6,6</Thickness>
<sys:Double x:Key="AppBarMoreButtonColumnMinWidth">6</sys:Double>

<Thickness x:Key="AppBarButtonContentViewboxMargin">12,16,0,10</Thickness>
<Thickness x:Key="AppBarButtonContentViewboxCompactMargin">0,12,0,12</Thickness>
Expand Down
24 changes: 24 additions & 0 deletions test/ModernWpfTestApp/CommandBarFlyoutPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,28 @@
<ui:AppBarButton x:Name="SelectAllButton7" AutomationProperties.AutomationId="SelectAllButton7" Label="Select all" Click="OnElementClicked" />
</muxc:CommandBarFlyout.SecondaryCommands>
</muxc:CommandBarFlyout>
<muxc:CommandBarFlyout Placement="Right" x:Key="Flyout8" AutomationProperties.AutomationId="Flyout8" Opened="OnFlyoutOpened" Closed="OnFlyoutClosed" AlwaysExpanded="true">
<AppBarButton x:Name="CutButton8" AutomationProperties.AutomationId="CutButton8" Label="Cut" Icon="Cut" Click="OnElementClicked" />
<AppBarButton x:Name="CopyButton8" AutomationProperties.AutomationId="CopyButton8" Label="Copy" Icon="Copy" Click="OnElementClicked" />
<AppBarButton x:Name="PasteButton8" AutomationProperties.AutomationId="PasteButton8" Label="Paste" Icon="Paste" Click="OnElementClicked" />
<AppBarButton x:Name="BoldButton8" AutomationProperties.AutomationId="BoldButton8" Label="Bold" Icon="Bold" Click="OnElementClicked" />
<AppBarButton x:Name="ItalicButton8" AutomationProperties.AutomationId="ItalicButton8" Label="Italic" Icon="Italic" Click="OnElementClicked" />
<AppBarButton x:Name="UnderlineButton8" AutomationProperties.AutomationId="UnderlineButton8" Label="Underline" Icon="Underline" Click="OnElementClicked" />
</muxc:CommandBarFlyout>
<muxc:CommandBarFlyout Placement="Right" x:Key="Flyout9" AutomationProperties.AutomationId="Flyout9" Opened="OnFlyoutOpened" Closed="OnFlyoutClosed" AlwaysExpanded="true">
<AppBarButton x:Name="CutButton9" AutomationProperties.AutomationId="CutButton9" Label="Cut" Icon="Cut" Click="OnElementClicked" />
<AppBarButton x:Name="CopyButton9" AutomationProperties.AutomationId="CopyButton9" Label="Copy" Icon="Copy" Click="OnElementClicked" />
<AppBarButton x:Name="PasteButton9" AutomationProperties.AutomationId="PasteButton9" Label="Paste" Icon="Paste" Click="OnElementClicked" />
<AppBarButton x:Name="BoldButton9" AutomationProperties.AutomationId="BoldButton9" Label="Bold" Icon="Bold" Click="OnElementClicked" />
<AppBarButton x:Name="ItalicButton9" AutomationProperties.AutomationId="ItalicButton9" Label="Italic" Icon="Italic" Click="OnElementClicked" />
<AppBarButton x:Name="UnderlineButton9" AutomationProperties.AutomationId="UnderlineButton9" Label="Underline" Icon="Underline" Click="OnElementClicked" />
<muxc:CommandBarFlyout.SecondaryCommands>
<AppBarButton x:Name="UndoButton9" AutomationProperties.AutomationId="UndoButton9" Label="Undo" Icon="Undo" Click="OnElementClicked" />
<AppBarButton x:Name="RedoButton9" AutomationProperties.AutomationId="RedoButton9" Label="Redo" Icon="Redo" Click="OnElementClicked" />
<AppBarButton x:Name="SelectAllButton9" AutomationProperties.AutomationId="SelectAllButton9" Label="Select all" Click="OnElementClicked" />
<AppBarToggleButton x:Name="FavoriteToggleButton9" AutomationProperties.AutomationId="FavoriteToggleButton9" Label="Favorite" Icon="Favorite" Checked="OnElementChecked" Unchecked="OnElementUnchecked" />
</muxc:CommandBarFlyout.SecondaryCommands>
</muxc:CommandBarFlyout>
</Grid.Resources>
<ScrollViewer>
<StackPanel>
Expand Down Expand Up @@ -209,6 +231,8 @@
Content="Show CommandBarFlyout with non-focusable primary commands"
Margin="10"
Click="OnFlyoutTarget7Click" />
<Button x:Name="FlyoutTarget8" Content="Show CommandBarFlyout with no secondary commands" Margin="10" Click="OnFlyoutTarget8Click" />
<Button x:Name="FlyoutTarget9" Content="Show CommandBarFlyout with AlwaysExpanded" Margin="10" Click="OnFlyoutTarget9Click" />
<CheckBox
x:Name="IsRTLCheckBox"
Content="Is Page in RightToLeft FlowDirection?"
Expand Down
12 changes: 12 additions & 0 deletions test/ModernWpfTestApp/CommandBarFlyoutPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public sealed partial class CommandBarFlyoutPage : TestPage
CommandBarFlyout Flyout5 => GetResource<CommandBarFlyout>();
CommandBarFlyout Flyout6 => GetResource<CommandBarFlyout>();
CommandBarFlyout Flyout7 => GetResource<CommandBarFlyout>();
CommandBarFlyout Flyout8 => GetResource<CommandBarFlyout>();
CommandBarFlyout Flyout9 => GetResource<CommandBarFlyout>();

public CommandBarFlyoutPage()
{
Expand Down Expand Up @@ -148,6 +150,16 @@ private void OnFlyoutTarget7Click(object sender, RoutedEventArgs e)
ShowFlyoutAt(Flyout7, FlyoutTarget7);
}

private void OnFlyoutTarget8Click(object sender, RoutedEventArgs e)
{
ShowFlyoutAt(Flyout8, FlyoutTarget8);
}

private void OnFlyoutTarget9Click(object sender, RoutedEventArgs e)
{
ShowFlyoutAt(Flyout9, FlyoutTarget9);
}

private void ShowFlyoutAt(FlyoutBase flyout, FrameworkElement targetElement, FlyoutShowMode showMode = FlyoutShowMode.Transient)
{
//if (PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone5))
Expand Down
8 changes: 1 addition & 7 deletions test/ModernWpfTestApp/CommandBarPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,12 @@
</CommandBar.SecondaryCommands>
</CommandBar>

<CommandBar DefaultLabelPosition="Right">
<CommandBar DefaultLabelPosition="Right" OverflowButtonVisibility="Collapsed">
<AppBarButton Icon="Add" Label="Add"/>
<AppBarButton Icon="Remove" Label="Remove"/>
<AppBarSeparator/>
<AppBarButton Icon="Save" Label="Save"/>
<AppBarToggleButton Icon="Add" Label="Toggle"/>
<CommandBar.SecondaryCommands>
<AppBarButton Icon="Add" Label="Add"/>
<AppBarButton Icon="Remove" Label="Remove"/>
<AppBarSeparator/>
<AppBarToggleButton Icon="Add" Label="Toggle"/>
</CommandBar.SecondaryCommands>
</CommandBar>

<CommandBar DefaultLabelPosition="Collapsed">
Expand Down

0 comments on commit e5c8538

Please sign in to comment.