mirror of
https://gitee.com/chinware/atomui.git
synced 2024-11-29 18:38:16 +08:00
Add BaseNavMenuItemTheme class
This commit is contained in:
parent
239a8c9c9e
commit
e9abcd5b81
@ -9,189 +9,210 @@
|
||||
|
||||
mc:Ignorable="d">
|
||||
<desktop:ShowCasePanel>
|
||||
<!-- <desktop:ShowCaseItem -->
|
||||
<!-- Title="Basic" -->
|
||||
<!-- Description="Simplest Usage."> -->
|
||||
<!-- <atom:Menu> -->
|
||||
<!-- <atom:MenuItem Header="_File"> -->
|
||||
<!-- <atom:MenuItem Header="New Text File" InputGesture="Ctrl+N" /> -->
|
||||
<!-- <atom:MenuItem Header="New File" InputGesture="Ctrl+Alt+N" /> -->
|
||||
<!-- <atom:MenuItem Header="New Window" InputGesture="Ctrl+Shift+N" /> -->
|
||||
<!-- </atom:MenuItem> -->
|
||||
<!-- <atom:MenuItem Header="_Edit"> -->
|
||||
<!-- <atom:MenuItem Header="Undo" InputGesture="Ctrl+Shift+Z" /> -->
|
||||
<!-- <atom:MenuSeparator /> -->
|
||||
<!-- <atom:MenuItem Header="Cut" InputGesture="Ctrl+X" /> -->
|
||||
<!-- </atom:MenuItem> -->
|
||||
<!-- <atom:MenuItem Header="Disabled Item" IsEnabled="False" /> -->
|
||||
<!-- </atom:Menu> -->
|
||||
<!-- </desktop:ShowCaseItem> -->
|
||||
<!-- -->
|
||||
<!-- <desktop:ShowCaseItem -->
|
||||
<!-- Title="Icon and submenu" -->
|
||||
<!-- Description="With icon and submenu."> -->
|
||||
<!-- <atom:Menu> -->
|
||||
<!-- <atom:MenuItem Header="_File"> -->
|
||||
<!-- <atom:MenuItem Header="New Text File" InputGesture="Ctrl+N" /> -->
|
||||
<!-- <atom:MenuItem Header="New File" InputGesture="Ctrl+Alt+N" /> -->
|
||||
<!-- <atom:MenuItem Header="New Window" InputGesture="Ctrl+Shift+N" /> -->
|
||||
<!-- <atom:MenuSeparator /> -->
|
||||
<!-- <atom:MenuItem Header="Save" InputGesture="Ctrl+S" /> -->
|
||||
<!-- <atom:MenuItem Header="Save As..." InputGesture="Ctrl+Shift+S" /> -->
|
||||
<!-- <atom:MenuItem Header="Save All" InputGesture="Ctrl+K" /> -->
|
||||
<!-- <atom:MenuSeparator /> -->
|
||||
<!-- <atom:MenuItem Header="Exit" /> -->
|
||||
<!-- </atom:MenuItem> -->
|
||||
<!-- <atom:MenuItem Header="_Edit"> -->
|
||||
<!-- <atom:MenuItem Header="Undo" InputGesture="Ctrl+Shift+Z" /> -->
|
||||
<!-- <atom:MenuSeparator /> -->
|
||||
<!-- <atom:MenuItem Header="Cut" InputGesture="Ctrl+X" Icon="{atom:IconProvider Kind=ScissorOutlined}" /> -->
|
||||
<!-- <atom:MenuItem Header="Copy" InputGesture="Ctrl+C" Icon="{atom:IconProvider Kind=CopyOutlined}" /> -->
|
||||
<!-- <atom:MenuItem Header="Delete" InputGesture="Ctrl+D" Icon="{atom:IconProvider Kind=DeleteOutlined}" /> -->
|
||||
<!-- <atom:MenuItem Header="Paste"> -->
|
||||
<!-- <atom:MenuItem Header="Paste" InputGesture="Ctrl+P" -->
|
||||
<!-- Icon="{atom:IconProvider Kind=FileDoneOutlined}" /> -->
|
||||
<!-- <atom:MenuItem Header="Paste from History" InputGesture="Ctrl+Shift+V" /> -->
|
||||
<!-- </atom:MenuItem> -->
|
||||
<!-- </atom:MenuItem> -->
|
||||
<!-- </atom:Menu> -->
|
||||
<!-- </desktop:ShowCaseItem> -->
|
||||
<!-- -->
|
||||
<!-- <desktop:ShowCaseItem -->
|
||||
<!-- Title="menu item with ToggleType" -->
|
||||
<!-- Description="Renders a checkbox or radio button on a menu."> -->
|
||||
<!-- <atom:Menu> -->
|
||||
<!-- <atom:MenuItem Header="_Menu A"> -->
|
||||
<!-- <atom:MenuItem Header="New Text File" InputGesture="Ctrl+N" ToggleType="Radio" GroupName="Group1" /> -->
|
||||
<!-- <atom:MenuItem Header="New File" InputGesture="Ctrl+Alt+N" ToggleType="Radio" GroupName="Group1" /> -->
|
||||
<!-- <atom:MenuItem Header="New Window" InputGesture="Ctrl+Shift+N" ToggleType="Radio" -->
|
||||
<!-- GroupName="Group1" /> -->
|
||||
<!-- <atom:MenuSeparator /> -->
|
||||
<!-- <atom:MenuItem Header="Save" InputGesture="Ctrl+S" ToggleType="CheckBox" /> -->
|
||||
<!-- <atom:MenuItem Header="Save As..." InputGesture="Ctrl+Shift+S" ToggleType="CheckBox" -->
|
||||
<!-- Icon="{atom:IconProvider Kind=GithubOutlined}" /> -->
|
||||
<!-- <atom:MenuItem Header="Save All" InputGesture="Ctrl+K" ToggleType="CheckBox" -->
|
||||
<!-- Icon="{atom:IconProvider Kind=CheckOutlined}" /> -->
|
||||
<!-- <atom:MenuSeparator /> -->
|
||||
<!-- <atom:MenuItem Header="Exit" /> -->
|
||||
<!-- <atom:MenuItem Header="Disabled" IsEnabled="False" /> -->
|
||||
<!-- </atom:MenuItem> -->
|
||||
<!-- </atom:Menu> -->
|
||||
<!-- </desktop:ShowCaseItem> -->
|
||||
<!-- -->
|
||||
<!-- <desktop:ShowCaseItem -->
|
||||
<!-- Title="Scrollable menu" -->
|
||||
<!-- Description="When there are too many menu items, up and down scroll buttons will appear."> -->
|
||||
<!-- <atom:Menu> -->
|
||||
<!-- <atom:MenuItem Header="_Menu"> -->
|
||||
<!-- <atom:MenuItem Header="Menu Item" /> -->
|
||||
<!-- <atom:MenuItem Header="Menu Item" /> -->
|
||||
<!-- <atom:MenuItem Header="Menu Item" /> -->
|
||||
<!-- <atom:MenuItem Header="Menu Item" /> -->
|
||||
<!-- <atom:MenuItem Header="Menu Item" /> -->
|
||||
<!-- <atom:MenuItem Header="Menu Item" /> -->
|
||||
<!-- <atom:MenuItem Header="Menu Item" /> -->
|
||||
<!-- <atom:MenuItem Header="Menu Item" /> -->
|
||||
<!-- <atom:MenuItem Header="Menu Item" /> -->
|
||||
<!-- <atom:MenuItem Header="Menu Item" /> -->
|
||||
<!-- <atom:MenuItem Header="Menu Item" /> -->
|
||||
<!-- <atom:MenuItem Header="Menu Item" /> -->
|
||||
<!-- <atom:MenuItem Header="Menu Item" /> -->
|
||||
<!-- <atom:MenuItem Header="Menu Item" /> -->
|
||||
<!-- <atom:MenuItem Header="Menu Item" /> -->
|
||||
<!-- <atom:MenuItem Header="Menu Item" /> -->
|
||||
<!-- <atom:MenuItem Header="Menu Item" /> -->
|
||||
<!-- <atom:MenuItem Header="Menu Item" /> -->
|
||||
<!-- <atom:MenuItem Header="Menu Item" /> -->
|
||||
<!-- <atom:MenuItem Header="Menu Item" /> -->
|
||||
<!-- <atom:MenuItem Header="Menu Item" /> -->
|
||||
<!-- <atom:MenuItem Header="Menu Item" /> -->
|
||||
<!-- <atom:MenuItem Header="Menu Item" /> -->
|
||||
<!-- <atom:MenuItem Header="Menu Item" /> -->
|
||||
<!-- <atom:MenuItem Header="Menu Item" /> -->
|
||||
<!-- <atom:MenuItem Header="Menu Item" /> -->
|
||||
<!-- <atom:MenuItem Header="Menu Item" /> -->
|
||||
<!-- <atom:MenuItem Header="Menu Item" /> -->
|
||||
<!-- <atom:MenuItem Header="Menu Item" /> -->
|
||||
<!-- <atom:MenuItem Header="Menu Item" /> -->
|
||||
<!-- <atom:MenuItem Header="Menu Item" /> -->
|
||||
<!-- <atom:MenuItem Header="Menu Item" /> -->
|
||||
<!-- <atom:MenuItem Header="Menu Item" /> -->
|
||||
<!-- <atom:MenuItem Header="Menu Item" /> -->
|
||||
<!-- <atom:MenuItem Header="Menu Item" /> -->
|
||||
<!-- <atom:MenuItem Header="Menu Item" /> -->
|
||||
<!-- </atom:MenuItem> -->
|
||||
<!-- </atom:Menu> -->
|
||||
<!-- </desktop:ShowCaseItem> -->
|
||||
<!-- -->
|
||||
<!-- <desktop:ShowCaseItem -->
|
||||
<!-- Title="Context menu" -->
|
||||
<!-- Description="Right click to bring up the context menu."> -->
|
||||
<!-- <desktop:ShowCaseItem.Styles> -->
|
||||
<!-- <Style Selector="Border#ContextMenuContainer"> -->
|
||||
<!-- <Setter Property="BorderBrush" Value="Gray" /> -->
|
||||
<!-- <Setter Property="BorderThickness" Value="1" /> -->
|
||||
<!-- <Setter Property="CornerRadius" Value="6" /> -->
|
||||
<!-- <Setter Property="Padding" Value="10" /> -->
|
||||
<!-- <Setter Property="Margin" Value="10" /> -->
|
||||
<!-- </Style> -->
|
||||
<!-- </desktop:ShowCaseItem.Styles> -->
|
||||
<!-- <Border Name="ContextMenuContainer"> -->
|
||||
<!-- <Border.ContextMenu> -->
|
||||
<!-- <atom:ContextMenu> -->
|
||||
<!-- <atom:MenuItem Header="Cut" InputGesture="Ctrl+X" -->
|
||||
<!-- Icon="{atom:IconProvider Kind=ScissorOutlined}" /> -->
|
||||
<!-- <atom:MenuItem Header="Copy" InputGesture="Ctrl+C" Icon="{atom:IconProvider Kind=CopyOutlined}" /> -->
|
||||
<!-- <atom:MenuItem Header="Delete" InputGesture="Ctrl+D" -->
|
||||
<!-- Icon="{atom:IconProvider Kind=DeleteOutlined}" /> -->
|
||||
<!-- <atom:MenuItem Header="Paste"> -->
|
||||
<!-- <atom:MenuItem Header="Paste" InputGesture="Ctrl+P" -->
|
||||
<!-- Icon="{atom:IconProvider Kind=FileDoneOutlined}" /> -->
|
||||
<!-- <atom:MenuItem Header="Paste from History" InputGesture="Ctrl+Shift+V" /> -->
|
||||
<!-- </atom:MenuItem> -->
|
||||
<!-- </atom:ContextMenu> -->
|
||||
<!-- </Border.ContextMenu> -->
|
||||
<!-- <TextBlock Text="Right Click to show Context Menu" /> -->
|
||||
<!-- </Border> -->
|
||||
<!-- </desktop:ShowCaseItem> -->
|
||||
<!-- -->
|
||||
<!-- <desktop:ShowCaseItem -->
|
||||
<!-- Title="Menu Flyout" -->
|
||||
<!-- Description="Right Click to show Context Flyout"> -->
|
||||
<!-- <desktop:ShowCaseItem.Styles> -->
|
||||
<!-- <Style Selector="Border#ContextFlyoutContainer"> -->
|
||||
<!-- <Setter Property="BorderBrush" Value="Gray" /> -->
|
||||
<!-- <Setter Property="BorderThickness" Value="1" /> -->
|
||||
<!-- <Setter Property="CornerRadius" Value="6" /> -->
|
||||
<!-- <Setter Property="Padding" Value="10" /> -->
|
||||
<!-- <Setter Property="Margin" Value="10" /> -->
|
||||
<!-- </Style> -->
|
||||
<!-- </desktop:ShowCaseItem.Styles> -->
|
||||
<!-- -->
|
||||
<!-- <Border Name="ContextFlyoutContainer"> -->
|
||||
<!-- <Border.ContextFlyout> -->
|
||||
<!-- <atom:MenuFlyout> -->
|
||||
<!-- <atom:MenuItem Header="Cut" InputGesture="Ctrl+X" -->
|
||||
<!-- Icon="{atom:IconProvider Kind=ScissorOutlined}" /> -->
|
||||
<!-- <atom:MenuItem Header="Copy" InputGesture="Ctrl+C" Icon="{atom:IconProvider Kind=CopyOutlined}" /> -->
|
||||
<!-- <atom:MenuItem Header="Delete" InputGesture="Ctrl+D" -->
|
||||
<!-- Icon="{atom:IconProvider Kind=DeleteOutlined}" /> -->
|
||||
<!-- <atom:MenuItem Header="Paste"> -->
|
||||
<!-- <atom:MenuItem Header="Paste" InputGesture="Ctrl+P" -->
|
||||
<!-- Icon="{atom:IconProvider Kind=FileDoneOutlined}" /> -->
|
||||
<!-- <atom:MenuItem Header="Paste from History" InputGesture="Ctrl+Shift+V" /> -->
|
||||
<!-- </atom:MenuItem> -->
|
||||
<!-- </atom:MenuFlyout> -->
|
||||
<!-- </Border.ContextFlyout> -->
|
||||
<!-- <TextBlock Text="Right Click to show Context Flyout" /> -->
|
||||
<!-- </Border> -->
|
||||
<!-- -->
|
||||
<!-- </desktop:ShowCaseItem> -->
|
||||
|
||||
<!-- <desktop:ShowCaseItem -->
|
||||
<!-- Title="Top Navigation" -->
|
||||
<!-- Description="Horizontal top navigation menu."> -->
|
||||
<!-- <atom:NavMenu> -->
|
||||
<!-- <atom:NavMenuItem Header="Navigation One" Icon="{atom:IconProvider Kind=MailOutlined}" /> -->
|
||||
<!-- <atom:NavMenuItem Header="Navigation Two" Icon="{atom:IconProvider Kind=AppstoreOutlined}" IsEnabled="False"/> -->
|
||||
<!-- <atom:NavMenuItem Header="Navigation Three - Submenu" Icon="{atom:IconProvider Kind=SettingOutlined}"> -->
|
||||
<!-- <atom:NavMenuItem Header="Item 1"> -->
|
||||
<!-- <atom:NavMenuItem Header="Option 1" /> -->
|
||||
<!-- <atom:NavMenuItem Header="Option 2" /> -->
|
||||
<!-- </atom:NavMenuItem> -->
|
||||
<!-- -->
|
||||
<!-- <atom:NavMenuItem Header="Item 2"> -->
|
||||
<!-- <atom:NavMenuItem Header="Option 3" /> -->
|
||||
<!-- <atom:NavMenuItem Header="Option 4" /> -->
|
||||
<!-- </atom:NavMenuItem> -->
|
||||
<!-- </atom:NavMenuItem> -->
|
||||
<!-- <atom:NavMenuItem Header="Navigation Four"/> -->
|
||||
<!-- </atom:NavMenu> -->
|
||||
<!-- </desktop:ShowCaseItem> -->
|
||||
|
||||
<desktop:ShowCaseItem
|
||||
Title="Basic"
|
||||
Description="Simplest Usage.">
|
||||
<atom:Menu>
|
||||
<atom:MenuItem Header="_File">
|
||||
<atom:MenuItem Header="New Text File" InputGesture="Ctrl+N" />
|
||||
<atom:MenuItem Header="New File" InputGesture="Ctrl+Alt+N" />
|
||||
<atom:MenuItem Header="New Window" InputGesture="Ctrl+Shift+N" />
|
||||
</atom:MenuItem>
|
||||
<atom:MenuItem Header="_Edit">
|
||||
<atom:MenuItem Header="Undo" InputGesture="Ctrl+Shift+Z" />
|
||||
<atom:MenuSeparator />
|
||||
<atom:MenuItem Header="Cut" InputGesture="Ctrl+X" />
|
||||
</atom:MenuItem>
|
||||
<atom:MenuItem Header="Disabled Item" IsEnabled="False" />
|
||||
</atom:Menu>
|
||||
</desktop:ShowCaseItem>
|
||||
|
||||
<desktop:ShowCaseItem
|
||||
Title="Icon and submenu"
|
||||
Description="With icon and submenu.">
|
||||
<atom:Menu>
|
||||
<atom:MenuItem Header="_File">
|
||||
<atom:MenuItem Header="New Text File" InputGesture="Ctrl+N" />
|
||||
<atom:MenuItem Header="New File" InputGesture="Ctrl+Alt+N" />
|
||||
<atom:MenuItem Header="New Window" InputGesture="Ctrl+Shift+N" />
|
||||
<atom:MenuSeparator />
|
||||
<atom:MenuItem Header="Save" InputGesture="Ctrl+S" />
|
||||
<atom:MenuItem Header="Save As..." InputGesture="Ctrl+Shift+S" />
|
||||
<atom:MenuItem Header="Save All" InputGesture="Ctrl+K" />
|
||||
<atom:MenuSeparator />
|
||||
<atom:MenuItem Header="Exit" />
|
||||
</atom:MenuItem>
|
||||
<atom:MenuItem Header="_Edit">
|
||||
<atom:MenuItem Header="Undo" InputGesture="Ctrl+Shift+Z" />
|
||||
<atom:MenuSeparator />
|
||||
<atom:MenuItem Header="Cut" InputGesture="Ctrl+X" Icon="{atom:IconProvider Kind=ScissorOutlined}" />
|
||||
<atom:MenuItem Header="Copy" InputGesture="Ctrl+C" Icon="{atom:IconProvider Kind=CopyOutlined}" />
|
||||
<atom:MenuItem Header="Delete" InputGesture="Ctrl+D" Icon="{atom:IconProvider Kind=DeleteOutlined}" />
|
||||
<atom:MenuItem Header="Paste">
|
||||
<atom:MenuItem Header="Paste" InputGesture="Ctrl+P"
|
||||
Icon="{atom:IconProvider Kind=FileDoneOutlined}" />
|
||||
<atom:MenuItem Header="Paste from History" InputGesture="Ctrl+Shift+V" />
|
||||
</atom:MenuItem>
|
||||
</atom:MenuItem>
|
||||
</atom:Menu>
|
||||
</desktop:ShowCaseItem>
|
||||
|
||||
<desktop:ShowCaseItem
|
||||
Title="menu item with ToggleType"
|
||||
Description="Renders a checkbox or radio button on a menu.">
|
||||
<atom:Menu>
|
||||
<atom:MenuItem Header="_Menu A">
|
||||
<atom:MenuItem Header="New Text File" InputGesture="Ctrl+N" ToggleType="Radio" GroupName="Group1" />
|
||||
<atom:MenuItem Header="New File" InputGesture="Ctrl+Alt+N" ToggleType="Radio" GroupName="Group1" />
|
||||
<atom:MenuItem Header="New Window" InputGesture="Ctrl+Shift+N" ToggleType="Radio"
|
||||
GroupName="Group1" />
|
||||
<atom:MenuSeparator />
|
||||
<atom:MenuItem Header="Save" InputGesture="Ctrl+S" ToggleType="CheckBox" />
|
||||
<atom:MenuItem Header="Save As..." InputGesture="Ctrl+Shift+S" ToggleType="CheckBox"
|
||||
Icon="{atom:IconProvider Kind=GithubOutlined}" />
|
||||
<atom:MenuItem Header="Save All" InputGesture="Ctrl+K" ToggleType="CheckBox"
|
||||
Icon="{atom:IconProvider Kind=CheckOutlined}" />
|
||||
<atom:MenuSeparator />
|
||||
<atom:MenuItem Header="Exit" />
|
||||
<atom:MenuItem Header="Disabled" IsEnabled="False" />
|
||||
</atom:MenuItem>
|
||||
</atom:Menu>
|
||||
</desktop:ShowCaseItem>
|
||||
|
||||
<desktop:ShowCaseItem
|
||||
Title="Scrollable menu"
|
||||
Description="When there are too many menu items, up and down scroll buttons will appear.">
|
||||
<atom:Menu>
|
||||
<atom:MenuItem Header="_Menu">
|
||||
<atom:MenuItem Header="Menu Item" />
|
||||
<atom:MenuItem Header="Menu Item" />
|
||||
<atom:MenuItem Header="Menu Item" />
|
||||
<atom:MenuItem Header="Menu Item" />
|
||||
<atom:MenuItem Header="Menu Item" />
|
||||
<atom:MenuItem Header="Menu Item" />
|
||||
<atom:MenuItem Header="Menu Item" />
|
||||
<atom:MenuItem Header="Menu Item" />
|
||||
<atom:MenuItem Header="Menu Item" />
|
||||
<atom:MenuItem Header="Menu Item" />
|
||||
<atom:MenuItem Header="Menu Item" />
|
||||
<atom:MenuItem Header="Menu Item" />
|
||||
<atom:MenuItem Header="Menu Item" />
|
||||
<atom:MenuItem Header="Menu Item" />
|
||||
<atom:MenuItem Header="Menu Item" />
|
||||
<atom:MenuItem Header="Menu Item" />
|
||||
<atom:MenuItem Header="Menu Item" />
|
||||
<atom:MenuItem Header="Menu Item" />
|
||||
<atom:MenuItem Header="Menu Item" />
|
||||
<atom:MenuItem Header="Menu Item" />
|
||||
<atom:MenuItem Header="Menu Item" />
|
||||
<atom:MenuItem Header="Menu Item" />
|
||||
<atom:MenuItem Header="Menu Item" />
|
||||
<atom:MenuItem Header="Menu Item" />
|
||||
<atom:MenuItem Header="Menu Item" />
|
||||
<atom:MenuItem Header="Menu Item" />
|
||||
<atom:MenuItem Header="Menu Item" />
|
||||
<atom:MenuItem Header="Menu Item" />
|
||||
<atom:MenuItem Header="Menu Item" />
|
||||
<atom:MenuItem Header="Menu Item" />
|
||||
<atom:MenuItem Header="Menu Item" />
|
||||
<atom:MenuItem Header="Menu Item" />
|
||||
<atom:MenuItem Header="Menu Item" />
|
||||
<atom:MenuItem Header="Menu Item" />
|
||||
<atom:MenuItem Header="Menu Item" />
|
||||
<atom:MenuItem Header="Menu Item" />
|
||||
</atom:MenuItem>
|
||||
</atom:Menu>
|
||||
</desktop:ShowCaseItem>
|
||||
|
||||
<desktop:ShowCaseItem
|
||||
Title="Context menu"
|
||||
Description="Right click to bring up the context menu.">
|
||||
<desktop:ShowCaseItem.Styles>
|
||||
<Style Selector="Border#ContextMenuContainer">
|
||||
<Setter Property="BorderBrush" Value="Gray" />
|
||||
<Setter Property="BorderThickness" Value="1" />
|
||||
<Setter Property="CornerRadius" Value="6" />
|
||||
<Setter Property="Padding" Value="10" />
|
||||
<Setter Property="Margin" Value="10" />
|
||||
</Style>
|
||||
</desktop:ShowCaseItem.Styles>
|
||||
<Border Name="ContextMenuContainer">
|
||||
<Border.ContextMenu>
|
||||
<atom:ContextMenu>
|
||||
<atom:MenuItem Header="Cut" InputGesture="Ctrl+X"
|
||||
Icon="{atom:IconProvider Kind=ScissorOutlined}" />
|
||||
<atom:MenuItem Header="Copy" InputGesture="Ctrl+C" Icon="{atom:IconProvider Kind=CopyOutlined}" />
|
||||
<atom:MenuItem Header="Delete" InputGesture="Ctrl+D"
|
||||
Icon="{atom:IconProvider Kind=DeleteOutlined}" />
|
||||
<atom:MenuItem Header="Paste">
|
||||
<atom:MenuItem Header="Paste" InputGesture="Ctrl+P"
|
||||
Icon="{atom:IconProvider Kind=FileDoneOutlined}" />
|
||||
<atom:MenuItem Header="Paste from History" InputGesture="Ctrl+Shift+V" />
|
||||
</atom:MenuItem>
|
||||
</atom:ContextMenu>
|
||||
</Border.ContextMenu>
|
||||
<TextBlock Text="Right Click to show Context Menu" />
|
||||
</Border>
|
||||
</desktop:ShowCaseItem>
|
||||
|
||||
<desktop:ShowCaseItem
|
||||
Title="Menu Flyout"
|
||||
Description="Right Click to show Context Flyout">
|
||||
<desktop:ShowCaseItem.Styles>
|
||||
<Style Selector="Border#ContextFlyoutContainer">
|
||||
<Setter Property="BorderBrush" Value="Gray" />
|
||||
<Setter Property="BorderThickness" Value="1" />
|
||||
<Setter Property="CornerRadius" Value="6" />
|
||||
<Setter Property="Padding" Value="10" />
|
||||
<Setter Property="Margin" Value="10" />
|
||||
</Style>
|
||||
</desktop:ShowCaseItem.Styles>
|
||||
|
||||
<Border Name="ContextFlyoutContainer">
|
||||
<Border.ContextFlyout>
|
||||
<atom:MenuFlyout>
|
||||
<atom:MenuItem Header="Cut" InputGesture="Ctrl+X"
|
||||
Icon="{atom:IconProvider Kind=ScissorOutlined}" />
|
||||
<atom:MenuItem Header="Copy" InputGesture="Ctrl+C" Icon="{atom:IconProvider Kind=CopyOutlined}" />
|
||||
<atom:MenuItem Header="Delete" InputGesture="Ctrl+D"
|
||||
Icon="{atom:IconProvider Kind=DeleteOutlined}" />
|
||||
<atom:MenuItem Header="Paste">
|
||||
<atom:MenuItem Header="Paste" InputGesture="Ctrl+P"
|
||||
Icon="{atom:IconProvider Kind=FileDoneOutlined}" />
|
||||
<atom:MenuItem Header="Paste from History" InputGesture="Ctrl+Shift+V" />
|
||||
</atom:MenuItem>
|
||||
</atom:MenuFlyout>
|
||||
</Border.ContextFlyout>
|
||||
<TextBlock Text="Right Click to show Context Flyout" />
|
||||
</Border>
|
||||
|
||||
</desktop:ShowCaseItem>
|
||||
|
||||
<desktop:ShowCaseItem
|
||||
Title="Top Navigation"
|
||||
Description="Horizontal top navigation menu.">
|
||||
<atom:NavMenu>
|
||||
Title="Vertical menu"
|
||||
Description="Submenus open as pop-ups.">
|
||||
<atom:NavMenu Mode="Vertical" Width="256" Margin="0, 0, 0, 20">
|
||||
<atom:NavMenuItem Header="Navigation One" Icon="{atom:IconProvider Kind=MailOutlined}" />
|
||||
<atom:NavMenuItem Header="Navigation Two" Icon="{atom:IconProvider Kind=AppstoreOutlined}" IsEnabled="False"/>
|
||||
<atom:NavMenuItem Header="Navigation Three - Submenu" Icon="{atom:IconProvider Kind=SettingOutlined}">
|
||||
|
@ -66,10 +66,11 @@
|
||||
ThemeManager.Current.RegisterControlTheme(new AtomUI.Controls.TopLevelMenuItemTheme());
|
||||
ThemeManager.Current.RegisterControlTheme(new AtomUI.Controls.MessageCardTheme());
|
||||
ThemeManager.Current.RegisterControlTheme(new AtomUI.Controls.WindowMessageManagerTheme());
|
||||
ThemeManager.Current.RegisterControlTheme(new AtomUI.Controls.InlineNavMenuItemTheme());
|
||||
ThemeManager.Current.RegisterControlTheme(new AtomUI.Controls.NavMenuItemTheme());
|
||||
ThemeManager.Current.RegisterControlTheme(new AtomUI.Controls.NavMenuTheme());
|
||||
ThemeManager.Current.RegisterControlTheme(new AtomUI.Controls.TopLevelHorizontalNavMenuItemTheme());
|
||||
ThemeManager.Current.RegisterControlTheme(new AtomUI.Controls.TopLevelVerticalNavMenuItemTheme());
|
||||
ThemeManager.Current.RegisterControlTheme(new AtomUI.Controls.VerticalNavMenuItemTheme());
|
||||
ThemeManager.Current.RegisterControlTheme(new AtomUI.Controls.NotificationCardTheme());
|
||||
ThemeManager.Current.RegisterControlTheme(new AtomUI.Controls.WindowNotificationManagerTheme());
|
||||
ThemeManager.Current.RegisterControlTheme(new AtomUI.Controls.NumericUpDownTheme());
|
||||
|
256
src/AtomUI.Controls/NavMenu/BaseNavMenuItemTheme.cs
Normal file
256
src/AtomUI.Controls/NavMenu/BaseNavMenuItemTheme.cs
Normal file
@ -0,0 +1,256 @@
|
||||
using AtomUI.Icon;
|
||||
using AtomUI.Media;
|
||||
using AtomUI.Theme;
|
||||
using AtomUI.Theme.Styling;
|
||||
using AtomUI.Theme.Utils;
|
||||
using AtomUI.Utils;
|
||||
using Avalonia;
|
||||
using Avalonia.Animation;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.Presenters;
|
||||
using Avalonia.Controls.Primitives;
|
||||
using Avalonia.Controls.Templates;
|
||||
using Avalonia.Data;
|
||||
using Avalonia.Layout;
|
||||
using Avalonia.Media;
|
||||
using Avalonia.Styling;
|
||||
|
||||
namespace AtomUI.Controls;
|
||||
|
||||
internal class BaseNavMenuItemTheme : BaseControlTheme
|
||||
{
|
||||
public const string ItemDecoratorPart = "PART_ItemDecorator";
|
||||
public const string MainContainerPart = "PART_MainContainer";
|
||||
public const string ItemIconPresenterPart = "PART_ItemIconPresenter";
|
||||
public const string ItemTextPresenterPart = "PART_ItemTextPresenter";
|
||||
public const string InputGestureTextPart = "PART_InputGestureText";
|
||||
public const string MenuIndicatorIconPart = "PART_MenuIndicatorIcon";
|
||||
|
||||
protected BaseNavMenuItemTheme(Type targetType) : base(targetType)
|
||||
{
|
||||
}
|
||||
|
||||
protected override IControlTemplate BuildControlTemplate()
|
||||
{
|
||||
return new FuncControlTemplate<NavMenuItem>((item, scope) =>
|
||||
{
|
||||
BuildInstanceStyles(item);
|
||||
// 仅仅为了把 Popup 包进来,没有其他什么作用
|
||||
var layoutWrapper = new Panel();
|
||||
var container = new Border
|
||||
{
|
||||
Name = ItemDecoratorPart
|
||||
};
|
||||
|
||||
var transitions = new Transitions();
|
||||
transitions.Add(AnimationUtils.CreateTransition<SolidColorBrushTransition>(Border.BackgroundProperty));
|
||||
container.Transitions = transitions;
|
||||
|
||||
var layout = new Grid
|
||||
{
|
||||
Name = MainContainerPart,
|
||||
ColumnDefinitions =
|
||||
{
|
||||
new ColumnDefinition(GridLength.Auto)
|
||||
{
|
||||
SharedSizeGroup = ThemeConstants.IconPresenterSizeGroup
|
||||
},
|
||||
new ColumnDefinition(GridLength.Star),
|
||||
new ColumnDefinition(GridLength.Auto)
|
||||
{
|
||||
SharedSizeGroup = ThemeConstants.InputGestureTextSizeGroup
|
||||
},
|
||||
new ColumnDefinition(GridLength.Auto)
|
||||
{
|
||||
SharedSizeGroup = ThemeConstants.MenuIndicatorIconSizeGroup
|
||||
}
|
||||
}
|
||||
};
|
||||
layout.RegisterInNameScope(scope);
|
||||
|
||||
var iconPresenter = new Viewbox
|
||||
{
|
||||
Name = ItemIconPresenterPart,
|
||||
HorizontalAlignment = HorizontalAlignment.Center,
|
||||
VerticalAlignment = VerticalAlignment.Center,
|
||||
Stretch = Stretch.Uniform
|
||||
};
|
||||
|
||||
Grid.SetColumn(iconPresenter, 0);
|
||||
iconPresenter.RegisterInNameScope(scope);
|
||||
CreateTemplateParentBinding(iconPresenter, Viewbox.ChildProperty, NavMenuItem.IconProperty);
|
||||
TokenResourceBinder.CreateTokenBinding(iconPresenter, Layoutable.MarginProperty,
|
||||
NavMenuTokenResourceKey.ItemMargin);
|
||||
TokenResourceBinder.CreateGlobalTokenBinding(iconPresenter, Layoutable.WidthProperty,
|
||||
NavMenuTokenResourceKey.ItemIconSize);
|
||||
TokenResourceBinder.CreateGlobalTokenBinding(iconPresenter, Layoutable.HeightProperty,
|
||||
NavMenuTokenResourceKey.ItemIconSize);
|
||||
|
||||
var itemTextPresenter = new ContentPresenter
|
||||
{
|
||||
Name = ItemTextPresenterPart,
|
||||
HorizontalAlignment = HorizontalAlignment.Stretch,
|
||||
VerticalAlignment = VerticalAlignment.Center,
|
||||
RecognizesAccessKey = true,
|
||||
IsHitTestVisible = false
|
||||
};
|
||||
Grid.SetColumn(itemTextPresenter, 1);
|
||||
TokenResourceBinder.CreateTokenBinding(itemTextPresenter, Layoutable.MarginProperty,
|
||||
NavMenuTokenResourceKey.ItemMargin);
|
||||
CreateTemplateParentBinding(itemTextPresenter, ContentPresenter.ContentProperty,
|
||||
HeaderedSelectingItemsControl.HeaderProperty);
|
||||
CreateTemplateParentBinding(itemTextPresenter, ContentPresenter.ContentTemplateProperty,
|
||||
HeaderedSelectingItemsControl.HeaderTemplateProperty);
|
||||
|
||||
itemTextPresenter.RegisterInNameScope(scope);
|
||||
|
||||
var inputGestureText = new TextBlock
|
||||
{
|
||||
Name = InputGestureTextPart,
|
||||
HorizontalAlignment = HorizontalAlignment.Right,
|
||||
TextAlignment = TextAlignment.Right,
|
||||
VerticalAlignment = VerticalAlignment.Center
|
||||
};
|
||||
Grid.SetColumn(inputGestureText, 2);
|
||||
TokenResourceBinder.CreateTokenBinding(inputGestureText, Layoutable.MarginProperty,
|
||||
NavMenuTokenResourceKey.ItemMargin);
|
||||
CreateTemplateParentBinding(inputGestureText,
|
||||
TextBlock.TextProperty,
|
||||
NavMenuItem.InputGestureProperty,
|
||||
BindingMode.Default,
|
||||
NavMenuItem.KeyGestureConverter);
|
||||
|
||||
inputGestureText.RegisterInNameScope(scope);
|
||||
|
||||
var menuIndicatorIcon = BuildMenuIndicatorIcon();
|
||||
Grid.SetColumn(menuIndicatorIcon, 3);
|
||||
menuIndicatorIcon.RegisterInNameScope(scope);
|
||||
|
||||
layout.Children.Add(iconPresenter);
|
||||
layout.Children.Add(itemTextPresenter);
|
||||
layout.Children.Add(inputGestureText);
|
||||
layout.Children.Add(menuIndicatorIcon);
|
||||
|
||||
BuildExtraItem(layout, scope);
|
||||
|
||||
container.Child = layout;
|
||||
layoutWrapper.Children.Add(container);
|
||||
return layoutWrapper;
|
||||
});
|
||||
}
|
||||
|
||||
protected virtual void BuildExtraItem(Grid containerLayout, INameScope scope)
|
||||
{
|
||||
}
|
||||
|
||||
protected virtual Control BuildMenuIndicatorIcon()
|
||||
{
|
||||
var menuIndicatorIcon = new PathIcon
|
||||
{
|
||||
Name = MenuIndicatorIconPart,
|
||||
HorizontalAlignment = HorizontalAlignment.Right,
|
||||
VerticalAlignment = VerticalAlignment.Center,
|
||||
Kind = "RightOutlined"
|
||||
};
|
||||
|
||||
TokenResourceBinder.CreateGlobalTokenBinding(menuIndicatorIcon, Layoutable.WidthProperty,
|
||||
NavMenuTokenResourceKey.MenuArrowSize);
|
||||
TokenResourceBinder.CreateGlobalTokenBinding(menuIndicatorIcon, Layoutable.HeightProperty,
|
||||
NavMenuTokenResourceKey.MenuArrowSize);
|
||||
|
||||
return menuIndicatorIcon;
|
||||
}
|
||||
|
||||
protected override void BuildStyles()
|
||||
{
|
||||
BuildCommonStyle();
|
||||
BuildMenuIndicatorStyle();
|
||||
BuildMenuIconStyle();
|
||||
BuildDisabledStyle();
|
||||
}
|
||||
|
||||
private void BuildCommonStyle()
|
||||
{
|
||||
var commonStyle = new Style(selector => selector.Nesting());
|
||||
commonStyle.Add(TemplatedControl.ForegroundProperty, NavMenuTokenResourceKey.ItemColor);
|
||||
{
|
||||
var keyGestureStyle = new Style(selector => selector.Nesting().Template().Name(InputGestureTextPart));
|
||||
keyGestureStyle.Add(TextBlock.ForegroundProperty, NavMenuTokenResourceKey.KeyGestureColor);
|
||||
commonStyle.Add(keyGestureStyle);
|
||||
}
|
||||
{
|
||||
var borderStyle = new Style(selector => selector.Nesting().Template().Name(ItemDecoratorPart));
|
||||
borderStyle.Add(Layoutable.MinHeightProperty, NavMenuTokenResourceKey.ItemHeight);
|
||||
borderStyle.Add(Decorator.PaddingProperty, NavMenuTokenResourceKey.ItemContentPadding);
|
||||
borderStyle.Add(Border.BackgroundProperty, NavMenuTokenResourceKey.ItemBg);
|
||||
borderStyle.Add(Border.CornerRadiusProperty, NavMenuTokenResourceKey.ItemBorderRadius);
|
||||
commonStyle.Add(borderStyle);
|
||||
}
|
||||
|
||||
// Hover 状态
|
||||
var hoverStyle = new Style(selector => selector.Nesting().Class(StdPseudoClass.PointerOver));
|
||||
hoverStyle.Add(TemplatedControl.ForegroundProperty, NavMenuTokenResourceKey.ItemHoverColor);
|
||||
{
|
||||
var borderStyle = new Style(selector => selector.Nesting().Template().Name(ItemDecoratorPart));
|
||||
borderStyle.Add(Border.BackgroundProperty, NavMenuTokenResourceKey.ItemHoverBg);
|
||||
hoverStyle.Add(borderStyle);
|
||||
}
|
||||
commonStyle.Add(hoverStyle);
|
||||
Add(commonStyle);
|
||||
}
|
||||
|
||||
private void BuildMenuIndicatorStyle()
|
||||
{
|
||||
{
|
||||
var menuIndicatorStyle = new Style(selector => selector.Nesting().Template().Name(MenuIndicatorIconPart));
|
||||
menuIndicatorStyle.Add(Visual.IsVisibleProperty, true);
|
||||
Add(menuIndicatorStyle);
|
||||
}
|
||||
var hasSubMenuStyle = new Style(selector => selector.Nesting().Class(StdPseudoClass.Empty));
|
||||
{
|
||||
var menuIndicatorStyle = new Style(selector => selector.Nesting().Template().Name(MenuIndicatorIconPart));
|
||||
menuIndicatorStyle.Add(Visual.IsVisibleProperty, false);
|
||||
hasSubMenuStyle.Add(menuIndicatorStyle);
|
||||
}
|
||||
Add(hasSubMenuStyle);
|
||||
}
|
||||
|
||||
private void BuildMenuIconStyle()
|
||||
{
|
||||
{
|
||||
var iconViewBoxStyle = new Style(selector => selector.Nesting().Template().Name(ItemIconPresenterPart));
|
||||
iconViewBoxStyle.Add(Visual.IsVisibleProperty, false);
|
||||
Add(iconViewBoxStyle);
|
||||
}
|
||||
|
||||
var hasIconStyle = new Style(selector => selector.Nesting().Class(":icon"));
|
||||
{
|
||||
var iconViewBoxStyle = new Style(selector => selector.Nesting().Template().Name(ItemIconPresenterPart));
|
||||
iconViewBoxStyle.Add(Visual.IsVisibleProperty, true);
|
||||
hasIconStyle.Add(iconViewBoxStyle);
|
||||
}
|
||||
Add(hasIconStyle);
|
||||
}
|
||||
|
||||
private void BuildDisabledStyle()
|
||||
{
|
||||
var disabledStyle = new Style(selector => selector.Nesting().Class(StdPseudoClass.Disabled));
|
||||
disabledStyle.Add(TemplatedControl.ForegroundProperty, NavMenuTokenResourceKey.ItemDisabledColor);
|
||||
Add(disabledStyle);
|
||||
}
|
||||
|
||||
protected override void BuildInstanceStyles(Control control)
|
||||
{
|
||||
var iconStyle = new Style(selector => selector.Name(ThemeConstants.ItemIconPart));
|
||||
iconStyle.Add(PathIcon.WidthProperty, NavMenuTokenResourceKey.ItemIconSize);
|
||||
iconStyle.Add(PathIcon.HeightProperty, NavMenuTokenResourceKey.ItemIconSize);
|
||||
iconStyle.Add(PathIcon.NormalFilledBrushProperty, GlobalTokenResourceKey.ColorText);
|
||||
iconStyle.Add(PathIcon.DisabledFilledBrushProperty, NavMenuTokenResourceKey.ItemDisabledColor);
|
||||
iconStyle.Add(PathIcon.SelectedFilledBrushProperty, GlobalTokenResourceKey.ColorPrimary);
|
||||
control.Styles.Add(iconStyle);
|
||||
|
||||
var disabledIconStyle = new Style(selector => selector.OfType<PathIcon>().Class(StdPseudoClass.Disabled));
|
||||
disabledIconStyle.Add(PathIcon.IconModeProperty, IconMode.Disabled);
|
||||
control.Styles.Add(disabledIconStyle);
|
||||
}
|
||||
}
|
14
src/AtomUI.Controls/NavMenu/InlineNavMenuItemTheme.cs
Normal file
14
src/AtomUI.Controls/NavMenu/InlineNavMenuItemTheme.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using AtomUI.Theme.Styling;
|
||||
|
||||
namespace AtomUI.Controls;
|
||||
|
||||
[ControlThemeProvider]
|
||||
internal class InlineNavMenuItemTheme : VerticalNavMenuItemTheme
|
||||
{
|
||||
public new const string ID = "InlineNavMenuItem";
|
||||
|
||||
public override string ThemeResourceKey()
|
||||
{
|
||||
return ID;
|
||||
}
|
||||
}
|
@ -215,14 +215,20 @@ public class NavMenu : NavMenuBase
|
||||
{
|
||||
if (ItemContainerTheme is null || force)
|
||||
{
|
||||
if (Mode == NavMenuMode.Inline || Mode == NavMenuMode.Vertical)
|
||||
var resourceKey = string.Empty;
|
||||
if (Mode == NavMenuMode.Vertical)
|
||||
{
|
||||
TokenResourceBinder.CreateGlobalResourceBinding(this, ItemContainerThemeProperty, TopLevelVerticalNavMenuItemTheme.ID);
|
||||
resourceKey = VerticalNavMenuItemTheme.ID;
|
||||
}
|
||||
else if (Mode == NavMenuMode.Inline)
|
||||
{
|
||||
resourceKey = InlineNavMenuItemTheme.ID;
|
||||
}
|
||||
else
|
||||
{
|
||||
TokenResourceBinder.CreateGlobalResourceBinding(this, ItemContainerThemeProperty, TopLevelHorizontalNavMenuItemTheme.ID);
|
||||
resourceKey = TopLevelHorizontalNavMenuItemTheme.ID;
|
||||
}
|
||||
TokenResourceBinder.CreateGlobalResourceBinding(this, ItemContainerThemeProperty, resourceKey);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
namespace AtomUI.Controls;
|
||||
|
||||
public class NavMenuItemInlineTheme
|
||||
{
|
||||
|
||||
}
|
@ -1,165 +1,40 @@
|
||||
using AtomUI.Icon;
|
||||
using AtomUI.Media;
|
||||
using AtomUI.Theme;
|
||||
using AtomUI.Theme;
|
||||
using AtomUI.Theme.Styling;
|
||||
using AtomUI.Theme.Utils;
|
||||
using AtomUI.Utils;
|
||||
using Avalonia;
|
||||
using Avalonia.Animation;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.Presenters;
|
||||
using Avalonia.Controls.Primitives;
|
||||
using Avalonia.Controls.Templates;
|
||||
using Avalonia.Data;
|
||||
using Avalonia.Layout;
|
||||
using Avalonia.Media;
|
||||
using Avalonia.Styling;
|
||||
|
||||
namespace AtomUI.Controls;
|
||||
|
||||
[ControlThemeProvider]
|
||||
internal class NavMenuItemTheme : BaseControlTheme
|
||||
internal class NavMenuItemTheme : BaseNavMenuItemTheme
|
||||
{
|
||||
public const string ItemDecoratorPart = "PART_ItemDecorator";
|
||||
public const string MainContainerPart = "PART_MainContainer";
|
||||
public const string ItemIconPresenterPart = "PART_ItemIconPresenter";
|
||||
public const string ItemTextPresenterPart = "PART_ItemTextPresenter";
|
||||
public const string InputGestureTextPart = "PART_InputGestureText";
|
||||
public const string MenuIndicatorIconPart = "PART_MenuIndicatorIcon";
|
||||
public const string PopupPart = "PART_Popup";
|
||||
public const string ItemsPresenterPart = "PART_ItemsPresenter";
|
||||
|
||||
public NavMenuItemTheme()
|
||||
: base(typeof(NavMenuItem))
|
||||
{
|
||||
}
|
||||
|
||||
protected override IControlTemplate BuildControlTemplate()
|
||||
|
||||
protected NavMenuItemTheme(Type targetType) : base(targetType)
|
||||
{
|
||||
return new FuncControlTemplate<NavMenuItem>((item, scope) =>
|
||||
{
|
||||
BuildInstanceStyles(item);
|
||||
// 仅仅为了把 Popup 包进来,没有其他什么作用
|
||||
var layoutWrapper = new Panel();
|
||||
var container = new Border
|
||||
{
|
||||
Name = ItemDecoratorPart
|
||||
};
|
||||
|
||||
var transitions = new Transitions();
|
||||
transitions.Add(AnimationUtils.CreateTransition<SolidColorBrushTransition>(Border.BackgroundProperty));
|
||||
container.Transitions = transitions;
|
||||
|
||||
var layout = new Grid
|
||||
{
|
||||
Name = MainContainerPart,
|
||||
ColumnDefinitions =
|
||||
{
|
||||
new ColumnDefinition(GridLength.Auto)
|
||||
{
|
||||
SharedSizeGroup = ThemeConstants.IconPresenterSizeGroup
|
||||
},
|
||||
new ColumnDefinition(GridLength.Star),
|
||||
new ColumnDefinition(GridLength.Auto)
|
||||
{
|
||||
SharedSizeGroup = ThemeConstants.InputGestureTextSizeGroup
|
||||
},
|
||||
new ColumnDefinition(GridLength.Auto)
|
||||
{
|
||||
SharedSizeGroup = ThemeConstants.MenuIndicatorIconSizeGroup
|
||||
}
|
||||
}
|
||||
};
|
||||
layout.RegisterInNameScope(scope);
|
||||
|
||||
var iconPresenter = new Viewbox
|
||||
{
|
||||
Name = ItemIconPresenterPart,
|
||||
HorizontalAlignment = HorizontalAlignment.Center,
|
||||
VerticalAlignment = VerticalAlignment.Center,
|
||||
Stretch = Stretch.Uniform
|
||||
};
|
||||
|
||||
Grid.SetColumn(iconPresenter, 0);
|
||||
iconPresenter.RegisterInNameScope(scope);
|
||||
CreateTemplateParentBinding(iconPresenter, Viewbox.ChildProperty, NavMenuItem.IconProperty);
|
||||
TokenResourceBinder.CreateTokenBinding(iconPresenter, Layoutable.MarginProperty,
|
||||
NavMenuTokenResourceKey.ItemMargin);
|
||||
TokenResourceBinder.CreateGlobalTokenBinding(iconPresenter, Layoutable.WidthProperty,
|
||||
NavMenuTokenResourceKey.ItemIconSize);
|
||||
TokenResourceBinder.CreateGlobalTokenBinding(iconPresenter, Layoutable.HeightProperty,
|
||||
NavMenuTokenResourceKey.ItemIconSize);
|
||||
|
||||
var itemTextPresenter = new ContentPresenter
|
||||
{
|
||||
Name = ItemTextPresenterPart,
|
||||
HorizontalAlignment = HorizontalAlignment.Stretch,
|
||||
VerticalAlignment = VerticalAlignment.Center,
|
||||
RecognizesAccessKey = true,
|
||||
IsHitTestVisible = false
|
||||
};
|
||||
Grid.SetColumn(itemTextPresenter, 1);
|
||||
TokenResourceBinder.CreateTokenBinding(itemTextPresenter, Layoutable.MarginProperty,
|
||||
NavMenuTokenResourceKey.ItemMargin);
|
||||
CreateTemplateParentBinding(itemTextPresenter, ContentPresenter.ContentProperty,
|
||||
HeaderedSelectingItemsControl.HeaderProperty);
|
||||
CreateTemplateParentBinding(itemTextPresenter, ContentPresenter.ContentTemplateProperty,
|
||||
HeaderedSelectingItemsControl.HeaderTemplateProperty);
|
||||
|
||||
itemTextPresenter.RegisterInNameScope(scope);
|
||||
|
||||
var inputGestureText = new TextBlock
|
||||
{
|
||||
Name = InputGestureTextPart,
|
||||
HorizontalAlignment = HorizontalAlignment.Right,
|
||||
TextAlignment = TextAlignment.Right,
|
||||
VerticalAlignment = VerticalAlignment.Center
|
||||
};
|
||||
Grid.SetColumn(inputGestureText, 2);
|
||||
TokenResourceBinder.CreateTokenBinding(inputGestureText, Layoutable.MarginProperty,
|
||||
NavMenuTokenResourceKey.ItemMargin);
|
||||
CreateTemplateParentBinding(inputGestureText,
|
||||
TextBlock.TextProperty,
|
||||
NavMenuItem.InputGestureProperty,
|
||||
BindingMode.Default,
|
||||
NavMenuItem.KeyGestureConverter);
|
||||
|
||||
inputGestureText.RegisterInNameScope(scope);
|
||||
|
||||
var menuIndicatorIcon = new PathIcon
|
||||
{
|
||||
Name = MenuIndicatorIconPart,
|
||||
HorizontalAlignment = HorizontalAlignment.Right,
|
||||
VerticalAlignment = VerticalAlignment.Center,
|
||||
Kind = "RightOutlined"
|
||||
};
|
||||
TokenResourceBinder.CreateGlobalTokenBinding(menuIndicatorIcon, Layoutable.WidthProperty,
|
||||
NavMenuTokenResourceKey.MenuArrowSize);
|
||||
TokenResourceBinder.CreateGlobalTokenBinding(menuIndicatorIcon, Layoutable.HeightProperty,
|
||||
NavMenuTokenResourceKey.MenuArrowSize);
|
||||
Grid.SetColumn(menuIndicatorIcon, 3);
|
||||
menuIndicatorIcon.RegisterInNameScope(scope);
|
||||
|
||||
var popup = CreateMenuPopup();
|
||||
popup.RegisterInNameScope(scope);
|
||||
|
||||
layout.Children.Add(iconPresenter);
|
||||
layout.Children.Add(itemTextPresenter);
|
||||
layout.Children.Add(inputGestureText);
|
||||
layout.Children.Add(menuIndicatorIcon);
|
||||
layout.Children.Add(popup);
|
||||
|
||||
container.Child = layout;
|
||||
layoutWrapper.Children.Add(container);
|
||||
return layoutWrapper;
|
||||
});
|
||||
}
|
||||
|
||||
private Popup CreateMenuPopup()
|
||||
|
||||
protected override void BuildExtraItem(Grid containerLayout, INameScope scope)
|
||||
{
|
||||
var popup = CreateMenuPopup();
|
||||
popup.RegisterInNameScope(scope);
|
||||
containerLayout.Children.Add(popup);
|
||||
}
|
||||
|
||||
protected Popup CreateMenuPopup()
|
||||
{
|
||||
var popup = new Popup
|
||||
{
|
||||
Name = PopupPart,
|
||||
Name = ThemeConstants.PopupPart,
|
||||
WindowManagerAddShadowHint = false,
|
||||
IsLightDismissEnabled = false,
|
||||
Placement = PlacementMode.RightEdgeAlignedTop
|
||||
@ -202,97 +77,4 @@ internal class NavMenuItemTheme : BaseControlTheme
|
||||
|
||||
return popup;
|
||||
}
|
||||
|
||||
protected override void BuildStyles()
|
||||
{
|
||||
BuildCommonStyle();
|
||||
BuildMenuIndicatorStyle();
|
||||
BuildMenuIconStyle();
|
||||
BuildDisabledStyle();
|
||||
}
|
||||
|
||||
private void BuildCommonStyle()
|
||||
{
|
||||
var commonStyle = new Style(selector => selector.Nesting());
|
||||
commonStyle.Add(TemplatedControl.ForegroundProperty, NavMenuTokenResourceKey.ItemColor);
|
||||
{
|
||||
var keyGestureStyle = new Style(selector => selector.Nesting().Template().Name(InputGestureTextPart));
|
||||
keyGestureStyle.Add(TextBlock.ForegroundProperty, NavMenuTokenResourceKey.KeyGestureColor);
|
||||
commonStyle.Add(keyGestureStyle);
|
||||
}
|
||||
{
|
||||
var borderStyle = new Style(selector => selector.Nesting().Template().Name(ItemDecoratorPart));
|
||||
borderStyle.Add(Layoutable.MinHeightProperty, NavMenuTokenResourceKey.ItemHeight);
|
||||
borderStyle.Add(Decorator.PaddingProperty, NavMenuTokenResourceKey.ItemContentPadding);
|
||||
borderStyle.Add(Border.BackgroundProperty, NavMenuTokenResourceKey.ItemBg);
|
||||
borderStyle.Add(Border.CornerRadiusProperty, NavMenuTokenResourceKey.ItemBorderRadius);
|
||||
commonStyle.Add(borderStyle);
|
||||
}
|
||||
|
||||
// Hover 状态
|
||||
var hoverStyle = new Style(selector => selector.Nesting().Class(StdPseudoClass.PointerOver));
|
||||
hoverStyle.Add(TemplatedControl.ForegroundProperty, NavMenuTokenResourceKey.ItemHoverColor);
|
||||
{
|
||||
var borderStyle = new Style(selector => selector.Nesting().Template().Name(ItemDecoratorPart));
|
||||
borderStyle.Add(Border.BackgroundProperty, NavMenuTokenResourceKey.ItemHoverBg);
|
||||
hoverStyle.Add(borderStyle);
|
||||
}
|
||||
commonStyle.Add(hoverStyle);
|
||||
Add(commonStyle);
|
||||
}
|
||||
|
||||
private void BuildMenuIndicatorStyle()
|
||||
{
|
||||
{
|
||||
var menuIndicatorStyle = new Style(selector => selector.Nesting().Template().Name(MenuIndicatorIconPart));
|
||||
menuIndicatorStyle.Add(Visual.IsVisibleProperty, true);
|
||||
Add(menuIndicatorStyle);
|
||||
}
|
||||
var hasSubMenuStyle = new Style(selector => selector.Nesting().Class(StdPseudoClass.Empty));
|
||||
{
|
||||
var menuIndicatorStyle = new Style(selector => selector.Nesting().Template().Name(MenuIndicatorIconPart));
|
||||
menuIndicatorStyle.Add(Visual.IsVisibleProperty, false);
|
||||
hasSubMenuStyle.Add(menuIndicatorStyle);
|
||||
}
|
||||
Add(hasSubMenuStyle);
|
||||
}
|
||||
|
||||
private void BuildMenuIconStyle()
|
||||
{
|
||||
{
|
||||
var iconViewBoxStyle = new Style(selector => selector.Nesting().Template().Name(ItemIconPresenterPart));
|
||||
iconViewBoxStyle.Add(Visual.IsVisibleProperty, false);
|
||||
Add(iconViewBoxStyle);
|
||||
}
|
||||
|
||||
var hasIconStyle = new Style(selector => selector.Nesting().Class(":icon"));
|
||||
{
|
||||
var iconViewBoxStyle = new Style(selector => selector.Nesting().Template().Name(ItemIconPresenterPart));
|
||||
iconViewBoxStyle.Add(Visual.IsVisibleProperty, true);
|
||||
hasIconStyle.Add(iconViewBoxStyle);
|
||||
}
|
||||
Add(hasIconStyle);
|
||||
}
|
||||
|
||||
private void BuildDisabledStyle()
|
||||
{
|
||||
var disabledStyle = new Style(selector => selector.Nesting().Class(StdPseudoClass.Disabled));
|
||||
disabledStyle.Add(TemplatedControl.ForegroundProperty, NavMenuTokenResourceKey.ItemDisabledColor);
|
||||
Add(disabledStyle);
|
||||
}
|
||||
|
||||
protected override void BuildInstanceStyles(Control control)
|
||||
{
|
||||
var iconStyle = new Style(selector => selector.Name(ThemeConstants.ItemIconPart));
|
||||
iconStyle.Add(PathIcon.WidthProperty, NavMenuTokenResourceKey.ItemIconSize);
|
||||
iconStyle.Add(PathIcon.HeightProperty, NavMenuTokenResourceKey.ItemIconSize);
|
||||
iconStyle.Add(PathIcon.NormalFilledBrushProperty, GlobalTokenResourceKey.ColorText);
|
||||
iconStyle.Add(PathIcon.DisabledFilledBrushProperty, NavMenuTokenResourceKey.ItemDisabledColor);
|
||||
iconStyle.Add(PathIcon.SelectedFilledBrushProperty, GlobalTokenResourceKey.ColorPrimary);
|
||||
control.Styles.Add(iconStyle);
|
||||
|
||||
var disabledIconStyle = new Style(selector => selector.OfType<PathIcon>().Class(StdPseudoClass.Disabled));
|
||||
disabledIconStyle.Add(PathIcon.IconModeProperty, IconMode.Disabled);
|
||||
control.Styles.Add(disabledIconStyle);
|
||||
}
|
||||
}
|
@ -7,6 +7,8 @@ using Avalonia.Controls.Presenters;
|
||||
using Avalonia.Controls.Primitives;
|
||||
using Avalonia.Controls.Shapes;
|
||||
using Avalonia.Controls.Templates;
|
||||
using Avalonia.Data;
|
||||
using Avalonia.Data.Converters;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Layout;
|
||||
using Avalonia.Styling;
|
||||
@ -23,13 +25,13 @@ internal class NavMenuTheme : BaseControlTheme
|
||||
{
|
||||
}
|
||||
|
||||
protected override IControlTemplate? BuildControlTemplate()
|
||||
protected override IControlTemplate BuildControlTemplate()
|
||||
{
|
||||
return new FuncControlTemplate<NavMenu>((menu, scope) =>
|
||||
{
|
||||
var itemPresenter = new ItemsPresenter
|
||||
{
|
||||
Name = ItemsPresenterPart,
|
||||
Name = ItemsPresenterPart
|
||||
};
|
||||
|
||||
KeyboardNavigation.SetTabNavigation(itemPresenter, KeyboardNavigationMode.Continue);
|
||||
@ -42,6 +44,8 @@ internal class NavMenuTheme : BaseControlTheme
|
||||
rootLayout.Children.Add(horizontalLine);
|
||||
DockPanel.SetDock(horizontalLine, Dock.Bottom);
|
||||
CreateTemplateParentBinding(horizontalLine, Rectangle.HeightProperty, NavMenu.HorizontalBorderThicknessProperty);
|
||||
CreateTemplateParentBinding(horizontalLine, Rectangle.IsVisibleProperty, NavMenu.ModeProperty, BindingMode.Default,
|
||||
new FuncValueConverter<NavMenuMode, bool>(v => v == NavMenuMode.Horizontal));
|
||||
TokenResourceBinder.CreateGlobalTokenBinding(horizontalLine, Rectangle.FillProperty, GlobalTokenResourceKey.ColorBorderSecondary);
|
||||
|
||||
var border = new Border
|
||||
@ -72,6 +76,8 @@ internal class NavMenuTheme : BaseControlTheme
|
||||
|
||||
var horizontalStyle = new Style(selector => selector.Nesting().Class(NavMenu.HorizontalModePC));
|
||||
horizontalStyle.Add(NavMenu.BackgroundProperty, GlobalTokenResourceKey.ColorBgContainer);
|
||||
horizontalStyle.Add(NavMenu.HorizontalAlignmentProperty, HorizontalAlignment.Stretch);
|
||||
horizontalStyle.Add(NavMenu.VerticalAlignmentProperty, VerticalAlignment.Top);
|
||||
horizontalStyle.Add(NavMenu.HeightProperty, NavMenuTokenResourceKey.MenuHorizontalHeight);
|
||||
{
|
||||
var itemPresenterStyle = new Style(selector => selector.Nesting().Template().Name(ItemsPresenterPart));
|
||||
@ -79,8 +85,6 @@ internal class NavMenuTheme : BaseControlTheme
|
||||
{
|
||||
Orientation = Orientation.Horizontal
|
||||
}));
|
||||
itemPresenterStyle.Add(ItemsPresenter.HorizontalAlignmentProperty, HorizontalAlignment.Stretch);
|
||||
itemPresenterStyle.Add(ItemsPresenter.VerticalAlignmentProperty, VerticalAlignment.Center);
|
||||
horizontalStyle.Add(itemPresenterStyle);
|
||||
}
|
||||
|
||||
@ -88,6 +92,8 @@ internal class NavMenuTheme : BaseControlTheme
|
||||
|
||||
var verticalOrInlineStyle = new Style(selector => Selectors.Or(selector.Nesting().Class(NavMenu.VerticalModePC),
|
||||
selector.Nesting().Class(NavMenu.InlineModePC)));
|
||||
verticalOrInlineStyle.Add(NavMenu.HorizontalAlignmentProperty, HorizontalAlignment.Left);
|
||||
verticalOrInlineStyle.Add(NavMenu.VerticalAlignmentProperty, VerticalAlignment.Stretch);
|
||||
verticalOrInlineStyle.Add(NavMenu.BackgroundProperty, GlobalTokenResourceKey.ColorBgContainer);
|
||||
var darkStyle = new Style(selector => selector.Nesting().Class(NavMenu.DarkStylePC));
|
||||
darkStyle.Add(NavMenu.BackgroundProperty, NavMenuTokenResourceKey.DarkItemBg);
|
||||
@ -99,8 +105,8 @@ internal class NavMenuTheme : BaseControlTheme
|
||||
{
|
||||
Orientation = Orientation.Vertical
|
||||
}));
|
||||
itemPresenterStyle.Add(ItemsPresenter.HorizontalAlignmentProperty, HorizontalAlignment.Left);
|
||||
itemPresenterStyle.Add(ItemsPresenter.VerticalAlignmentProperty, VerticalAlignment.Stretch);
|
||||
// itemPresenterStyle.Add(ItemsPresenter.HorizontalAlignmentProperty, HorizontalAlignment.Left);
|
||||
// itemPresenterStyle.Add(ItemsPresenter.VerticalAlignmentProperty, VerticalAlignment.Stretch);
|
||||
verticalOrInlineStyle.Add(itemPresenterStyle);
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ internal class NavMenuToken : AbstractControlDesignToken
|
||||
/// 顶层弹出菜单,距离顶层菜单项的边距
|
||||
/// </summary>
|
||||
public double TopLevelItemPopupMarginToAnchor { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 分组标题文字颜色
|
||||
/// </summary>
|
||||
|
@ -39,7 +39,7 @@ internal class TopLevelHorizontalNavMenuItemTheme : BaseControlTheme
|
||||
return ID;
|
||||
}
|
||||
|
||||
protected override IControlTemplate? BuildControlTemplate()
|
||||
protected override IControlTemplate BuildControlTemplate()
|
||||
{
|
||||
return new FuncControlTemplate<NavMenuItem>((menuItem, scope) =>
|
||||
{
|
||||
|
@ -1,19 +0,0 @@
|
||||
using AtomUI.Theme;
|
||||
using AtomUI.Theme.Styling;
|
||||
|
||||
namespace AtomUI.Controls;
|
||||
|
||||
[ControlThemeProvider]
|
||||
internal class TopLevelVerticalNavMenuItemTheme : BaseControlTheme
|
||||
{
|
||||
public const string ID = "TopLevelVerticalNavMenuItem";
|
||||
|
||||
public TopLevelVerticalNavMenuItemTheme() : base(typeof(NavMenuItem))
|
||||
{
|
||||
}
|
||||
|
||||
public override string ThemeResourceKey()
|
||||
{
|
||||
return ID;
|
||||
}
|
||||
}
|
22
src/AtomUI.Controls/NavMenu/VerticalNavMenuItemTheme.cs
Normal file
22
src/AtomUI.Controls/NavMenu/VerticalNavMenuItemTheme.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using AtomUI.Theme.Styling;
|
||||
|
||||
namespace AtomUI.Controls;
|
||||
|
||||
[ControlThemeProvider]
|
||||
internal class VerticalNavMenuItemTheme : NavMenuItemTheme
|
||||
{
|
||||
public const string ID = "VerticalNavMenuItem";
|
||||
|
||||
public VerticalNavMenuItemTheme() : this(typeof(NavMenuItem))
|
||||
{
|
||||
}
|
||||
|
||||
public VerticalNavMenuItemTheme(Type targetType) : base(targetType)
|
||||
{
|
||||
}
|
||||
|
||||
public override string ThemeResourceKey()
|
||||
{
|
||||
return ID;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user