WIP: init.
This commit is contained in:
@@ -51,5 +51,22 @@
|
|||||||
</u:SelectionList.ItemTemplate>
|
</u:SelectionList.ItemTemplate>
|
||||||
</u:SelectionList>
|
</u:SelectionList>
|
||||||
<Button Command="{Binding Clear}">Clear</Button>
|
<Button Command="{Binding Clear}">Clear</Button>
|
||||||
|
<u:NavMenu>
|
||||||
|
<u:NavMenuItem Header="Menu 1">
|
||||||
|
<u:NavMenuItem.Icon>
|
||||||
|
<Rectangle Width="10" Height="10" Fill="Red"></Rectangle>
|
||||||
|
</u:NavMenuItem.Icon>
|
||||||
|
</u:NavMenuItem>
|
||||||
|
<u:NavMenuItem Header="Menu 2">
|
||||||
|
<u:NavMenuItem.Icon>
|
||||||
|
<Rectangle Width="20" Height="10" Fill="Red"></Rectangle>
|
||||||
|
</u:NavMenuItem.Icon>
|
||||||
|
</u:NavMenuItem>
|
||||||
|
<u:NavMenuItem Header="Menu 3">
|
||||||
|
<u:NavMenuItem.Icon>
|
||||||
|
<Rectangle Width="30" Height="10" Fill="Red"></Rectangle>
|
||||||
|
</u:NavMenuItem.Icon>
|
||||||
|
</u:NavMenuItem>
|
||||||
|
</u:NavMenu>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
|||||||
32
src/Ursa.Themes.Semi/Controls/NavMenu.axaml
Normal file
32
src/Ursa.Themes.Semi/Controls/NavMenu.axaml
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<ResourceDictionary xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:u="https://irihi.tech/ursa">
|
||||||
|
<!-- Add Resources Here -->
|
||||||
|
<ControlTheme TargetType="u:NavMenu" x:Key="{x:Type u:NavMenu}">
|
||||||
|
<Setter Property="Template">
|
||||||
|
<ControlTemplate TargetType="u:NavMenu">
|
||||||
|
<ItemsPresenter ItemsPanel="{TemplateBinding ItemsPanel}" Grid.IsSharedSizeScope="True"/>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter>
|
||||||
|
</ControlTheme>
|
||||||
|
|
||||||
|
<ControlTheme TargetType="u:NavMenuItem" x:Key="{x:Type u:NavMenuItem}">
|
||||||
|
<Setter Property="Template">
|
||||||
|
<ControlTemplate TargetType="u:NavMenuItem">
|
||||||
|
<Expander>
|
||||||
|
<Expander.Header>
|
||||||
|
<Grid>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="Auto" SharedSizeGroup="Icon" />
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<ContentPresenter Content="{TemplateBinding Icon}" />
|
||||||
|
<ContentPresenter Grid.Column="1" Content="{TemplateBinding Header}" />
|
||||||
|
</Grid>
|
||||||
|
</Expander.Header>
|
||||||
|
<ItemsPresenter ItemsPanel="{TemplateBinding ItemsPanel}" />
|
||||||
|
</Expander>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter>
|
||||||
|
</ControlTheme>
|
||||||
|
</ResourceDictionary>
|
||||||
@@ -18,6 +18,7 @@
|
|||||||
<ResourceInclude Source="Loading.axaml" />
|
<ResourceInclude Source="Loading.axaml" />
|
||||||
<ResourceInclude Source="MessageBox.axaml" />
|
<ResourceInclude Source="MessageBox.axaml" />
|
||||||
<ResourceInclude Source="Navigation.axaml" />
|
<ResourceInclude Source="Navigation.axaml" />
|
||||||
|
<ResourceInclude Source="NavMenu.axaml" />
|
||||||
<ResourceInclude Source="NumericUpDown.axaml" />
|
<ResourceInclude Source="NumericUpDown.axaml" />
|
||||||
<ResourceInclude Source="Pagination.axaml" />
|
<ResourceInclude Source="Pagination.axaml" />
|
||||||
<ResourceInclude Source="RangeSlider.axaml" />
|
<ResourceInclude Source="RangeSlider.axaml" />
|
||||||
|
|||||||
17
src/Ursa/Controls/NavMenu/NavMenu.cs
Normal file
17
src/Ursa/Controls/NavMenu/NavMenu.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Controls.Primitives;
|
||||||
|
|
||||||
|
namespace Ursa.Controls;
|
||||||
|
|
||||||
|
public class NavMenu: SelectingItemsControl
|
||||||
|
{
|
||||||
|
protected override bool NeedsContainerOverride(object? item, int index, out object? recycleKey)
|
||||||
|
{
|
||||||
|
return NeedsContainer<NavMenuItem>(item, out recycleKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override Control CreateContainerForItemOverride(object? item, int index, object? recycleKey)
|
||||||
|
{
|
||||||
|
return new NavMenuItem();
|
||||||
|
}
|
||||||
|
}
|
||||||
27
src/Ursa/Controls/NavMenu/NavMenuItem.cs
Normal file
27
src/Ursa/Controls/NavMenu/NavMenuItem.cs
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
using Avalonia;
|
||||||
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Controls.Primitives;
|
||||||
|
|
||||||
|
namespace Ursa.Controls;
|
||||||
|
|
||||||
|
public class NavMenuItem: HeaderedSelectingItemsControl
|
||||||
|
{
|
||||||
|
public static readonly StyledProperty<object?> IconProperty = AvaloniaProperty.Register<NavMenuItem, object?>(
|
||||||
|
nameof(Icon));
|
||||||
|
|
||||||
|
public object? Icon
|
||||||
|
{
|
||||||
|
get => GetValue(IconProperty);
|
||||||
|
set => SetValue(IconProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool NeedsContainerOverride(object? item, int index, out object? recycleKey)
|
||||||
|
{
|
||||||
|
return NeedsContainer<NavMenuItem>(item, out recycleKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override Control CreateContainerForItemOverride(object? item, int index, object? recycleKey)
|
||||||
|
{
|
||||||
|
return new NavMenuItem();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user