feat: add demo.
This commit is contained in:
@@ -6,6 +6,7 @@ public static class MenuKeys
|
||||
public const string MenuKeyBadge = "Badge";
|
||||
public const string MenuKeyBanner = "Banner";
|
||||
public const string MenuKeyButtonGroup = "ButtonGroup";
|
||||
public const string MenuKeyBreadcrumb = "Breadcrumb";
|
||||
public const string MenuKeyClassInput = "Class Input";
|
||||
public const string MenuKeyDialog = "Dialog";
|
||||
public const string MenuKeyDivider = "Divider";
|
||||
|
||||
15
demo/Ursa.Demo/Pages/BreadcrumbDemo.axaml
Normal file
15
demo/Ursa.Demo/Pages/BreadcrumbDemo.axaml
Normal file
@@ -0,0 +1,15 @@
|
||||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:u="https://irihi.tech/ursa"
|
||||
mc:Ignorable="d" d:DesignWidth="800"
|
||||
d:DesignHeight="450"
|
||||
x:Class="Ursa.Demo.Pages.BreadcrumbDemo">
|
||||
<StackPanel>
|
||||
<u:Breadcrumb>
|
||||
<TextBlock Text="Hello"></TextBlock>
|
||||
<u:BreadcrumbItem Content="World" Icon="?"></u:BreadcrumbItem>
|
||||
</u:Breadcrumb>
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
13
demo/Ursa.Demo/Pages/BreadcrumbDemo.axaml.cs
Normal file
13
demo/Ursa.Demo/Pages/BreadcrumbDemo.axaml.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace Ursa.Demo.Pages;
|
||||
|
||||
public partial class BreadcrumbDemo : UserControl
|
||||
{
|
||||
public BreadcrumbDemo()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
8
demo/Ursa.Demo/ViewModels/BreadcrumbDemoViewModel.cs
Normal file
8
demo/Ursa.Demo/ViewModels/BreadcrumbDemoViewModel.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
|
||||
namespace Ursa.Demo.ViewModels;
|
||||
|
||||
public class BreadcrumbDemoViewModel: ObservableObject
|
||||
{
|
||||
|
||||
}
|
||||
@@ -28,6 +28,7 @@ public class MainViewViewModel : ViewModelBase
|
||||
MenuKeys.MenuKeyBadge => new BadgeDemoViewModel(),
|
||||
MenuKeys.MenuKeyBanner => new BannerDemoViewModel(),
|
||||
MenuKeys.MenuKeyButtonGroup => new ButtonGroupDemoViewModel(),
|
||||
MenuKeys.MenuKeyBreadcrumb => new BreadcrumbDemoViewModel(),
|
||||
MenuKeys.MenuKeyClassInput => new ClassInputDemoViewModel(),
|
||||
MenuKeys.MenuKeyDialog => new DialogDemoViewModel(),
|
||||
MenuKeys.MenuKeyDivider => new DividerDemoViewModel(),
|
||||
|
||||
@@ -14,6 +14,7 @@ public class MenuViewModel: ViewModelBase
|
||||
new() { MenuHeader = "Controls", IsSeparator = true },
|
||||
new() { MenuHeader = "Badge", Key = MenuKeys.MenuKeyBadge, Status = "Updated"},
|
||||
new() { MenuHeader = "Banner", Key = MenuKeys.MenuKeyBanner },
|
||||
new() { MenuHeader = "Breadcrumb", Key = MenuKeys.MenuKeyBreadcrumb, Status = "New" },
|
||||
new() { MenuHeader = "Button Group", Key = MenuKeys.MenuKeyButtonGroup},
|
||||
new() { MenuHeader = "Class Input", Key = MenuKeys.MenuKeyClassInput, Status = "New" },
|
||||
new() { MenuHeader = "Dialog", Key = MenuKeys.MenuKeyDialog, Status = "Updated"},
|
||||
|
||||
25
src/Ursa.Themes.Semi/Controls/Breadcrumb.axaml
Normal file
25
src/Ursa.Themes.Semi/Controls/Breadcrumb.axaml
Normal file
@@ -0,0 +1,25 @@
|
||||
<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 x:Key="{x:Type u:Breadcrumb}" TargetType="u:Breadcrumb">
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate TargetType="u:Breadcrumb">
|
||||
<ItemsPresenter ItemsPanel="{TemplateBinding ItemsPanel}" />
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
</ControlTheme>
|
||||
|
||||
<ControlTheme x:Key="{x:Type u:BreadcrumbItem}" TargetType="u:BreadcrumbItem">
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate TargetType="u:BreadcrumbItem">
|
||||
<Border BorderBrush="Red" BorderThickness="2" Margin="4">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<ContentPresenter Content="{TemplateBinding Icon}" />
|
||||
<ContentPresenter Name="PART_ContentPresenter" Content="{TemplateBinding Content}"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
</ControlTheme>
|
||||
</ResourceDictionary>
|
||||
@@ -4,6 +4,7 @@
|
||||
<ResourceInclude Source="Badge.axaml" />
|
||||
<ResourceInclude Source="Banner.axaml" />
|
||||
<ResourceInclude Source="ButtonGroup.axaml" />
|
||||
<ResourceInclude Source="Breadcrumb.axaml" />
|
||||
<ResourceInclude Source="ControlClassesInput.axaml" />
|
||||
<ResourceInclude Source="Dialog.axaml" />
|
||||
<ResourceInclude Source="DialogShared.axaml" />
|
||||
|
||||
@@ -4,6 +4,7 @@ using Avalonia.Controls.Templates;
|
||||
using Avalonia.Data;
|
||||
using Avalonia.Layout;
|
||||
using Avalonia.Metadata;
|
||||
using Irihi.Avalonia.Shared.Helpers;
|
||||
|
||||
namespace Ursa.Controls;
|
||||
|
||||
@@ -47,6 +48,15 @@ public class Breadcrumb: ItemsControl
|
||||
get => GetValue(SeparatorProperty);
|
||||
set => SetValue(SeparatorProperty, value);
|
||||
}
|
||||
|
||||
public static readonly StyledProperty<IDataTemplate?> IconTemplateProperty = AvaloniaProperty.Register<Breadcrumb, IDataTemplate?>(
|
||||
nameof(IconTemplate));
|
||||
|
||||
public IDataTemplate? IconTemplate
|
||||
{
|
||||
get => GetValue(IconTemplateProperty);
|
||||
set => SetValue(IconTemplateProperty, value);
|
||||
}
|
||||
|
||||
static Breadcrumb()
|
||||
{
|
||||
@@ -66,20 +76,23 @@ public class Breadcrumb: ItemsControl
|
||||
protected override void PrepareContainerForItemOverride(Control container, object? item, int index)
|
||||
{
|
||||
base.PrepareContainerForItemOverride(container, item, index);
|
||||
if (container is BreadcrumbItem breadcrumbItem)
|
||||
if (container is not BreadcrumbItem breadcrumbItem) return;
|
||||
if (!breadcrumbItem.IsSet(BreadcrumbItem.SeparatorProperty))
|
||||
{
|
||||
if (!breadcrumbItem.IsSet(BreadcrumbItem.SeparatorProperty))
|
||||
SeparatorProperty.Changed.AddClassHandler<Breadcrumb, object?>((o, e) =>
|
||||
{
|
||||
SeparatorProperty.Changed.AddClassHandler<Breadcrumb, object?>((o, e) =>
|
||||
breadcrumbItem.Separator = e.NewValue.Value switch
|
||||
{
|
||||
breadcrumbItem.Separator = e.NewValue.Value switch
|
||||
{
|
||||
string s => s,
|
||||
ITemplate<Control> t => t.Build(),
|
||||
_ => e.NewValue.Value?.ToString()
|
||||
};
|
||||
});
|
||||
}
|
||||
string s => s,
|
||||
ITemplate<Control> t => t.Build(),
|
||||
_ => e.NewValue.Value?.ToString()
|
||||
};
|
||||
});
|
||||
}
|
||||
bool b = breadcrumbItem.IsSet(BreadcrumbItem.IconProperty);
|
||||
if(!breadcrumbItem.IsSet(BreadcrumbItem.IconProperty) && IconBinding != null)
|
||||
{
|
||||
breadcrumbItem[!BreadcrumbItem.IconProperty] = IconBinding;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Windows.Input;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.Templates;
|
||||
|
||||
namespace Ursa.Controls;
|
||||
|
||||
@@ -34,6 +35,15 @@ public class BreadcrumbItem: ContentControl
|
||||
set => SetValue(CommandProperty, value);
|
||||
}
|
||||
|
||||
public static readonly StyledProperty<IDataTemplate?> IconTemplateProperty = AvaloniaProperty.Register<BreadcrumbItem, IDataTemplate?>(
|
||||
nameof(IconTemplate));
|
||||
|
||||
public IDataTemplate? IconTemplate
|
||||
{
|
||||
get => GetValue(IconTemplateProperty);
|
||||
set => SetValue(IconTemplateProperty, value);
|
||||
}
|
||||
|
||||
static BreadcrumbItem()
|
||||
{
|
||||
|
||||
|
||||
Reference in New Issue
Block a user