wip.
This commit is contained in:
@@ -7,7 +7,9 @@
|
||||
<Setter Property="Grid.IsSharedSizeScope" Value="True" />
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate TargetType="u:NavMenu">
|
||||
<ItemsPresenter ItemsPanel="{TemplateBinding ItemsPanel}" />
|
||||
<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
|
||||
<ItemsPresenter ItemsPanel="{TemplateBinding ItemsPanel}" />
|
||||
</ScrollViewer>
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
</ControlTheme>
|
||||
@@ -15,19 +17,22 @@
|
||||
<ControlTheme x:Key="{x:Type u:NavMenuItem}" TargetType="u:NavMenuItem">
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate TargetType="u:NavMenuItem">
|
||||
<Grid RowDefinitions="Auto, *">
|
||||
<Grid RowDefinitions="Auto, *" Background="{TemplateBinding Background}">
|
||||
<Grid Grid.Row="0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="Icon" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="*" SharedSizeGroup="Header" />
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="Expander" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<ContentPresenter
|
||||
HorizontalAlignment="Left"
|
||||
Background="Aqua"
|
||||
Padding="8"
|
||||
Background="Transparent"
|
||||
Content="{TemplateBinding Icon}" />
|
||||
<ContentPresenter
|
||||
Grid.Column="1"
|
||||
Background="LightYellow"
|
||||
Padding="0 8"
|
||||
Background="Transparent"
|
||||
Content="{TemplateBinding Header}" />
|
||||
</Grid>
|
||||
<ItemsPresenter
|
||||
@@ -38,5 +43,9 @@
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
|
||||
<Style Selector="^:selected">
|
||||
<Setter Property="Background" Value="{DynamicResource NavigationMenuItemSelectedBackground}" />
|
||||
</Style>
|
||||
</ControlTheme>
|
||||
</ResourceDictionary>
|
||||
|
||||
@@ -11,6 +11,12 @@ using Avalonia.VisualTree;
|
||||
|
||||
namespace Ursa.Controls;
|
||||
|
||||
/// <summary>
|
||||
/// Navigation Menu Item
|
||||
/// <para>Note:</para>
|
||||
/// <para>collapsed: Entire menu is collapsed, only first level icon is displayed. Submenus are in popup. </para>
|
||||
/// <para>closed: When menu is not in collapsed mode, represents whether submenu is hidden. </para>
|
||||
/// </summary>
|
||||
[PseudoClasses(PC_Highlighted, PC_Collapsed, PC_Closed, PC_FirstLevel, PC_Selector)]
|
||||
public class NavMenuItem: HeaderedSelectingItemsControl
|
||||
{
|
||||
@@ -145,7 +151,10 @@ public class NavMenuItem: HeaderedSelectingItemsControl
|
||||
protected override void OnPointerPressed(PointerPressedEventArgs e)
|
||||
{
|
||||
base.OnPointerPressed(e);
|
||||
SelectItem(this);
|
||||
if (this.ItemCount == 0)
|
||||
{
|
||||
SelectItem(this);
|
||||
}
|
||||
Command?.Execute(CommandParameter);
|
||||
e.Handled = true;
|
||||
}
|
||||
@@ -165,6 +174,14 @@ public class NavMenuItem: HeaderedSelectingItemsControl
|
||||
if (this.Parent is NavMenuItem menuItem)
|
||||
{
|
||||
menuItem.SelectItem(item);
|
||||
var items = menuItem.LogicalChildren.OfType<NavMenuItem>();
|
||||
foreach (var child in items)
|
||||
{
|
||||
if (child != this)
|
||||
{
|
||||
child.ClearSelection();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (this.Parent is NavMenu menu)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user