mirror of
https://gitcode.com/gh_mirrors/se/Semi.Avalonia
synced 2026-04-29 04:33:22 +08:00
feat: add basic IconDemo.
This commit is contained in:
10
demo/Semi.Avalonia.Demo/Pages/IconDemo.axaml
Normal file
10
demo/Semi.Avalonia.Demo/Pages/IconDemo.axaml
Normal file
@@ -0,0 +1,10 @@
|
||||
<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"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="Semi.Avalonia.Demo.Pages.IconDemo">
|
||||
<ScrollViewer>
|
||||
<StackPanel x:Name="IconsPanel" Orientation="Vertical" Spacing="10" Margin="10" />
|
||||
</ScrollViewer>
|
||||
</UserControl>
|
||||
45
demo/Semi.Avalonia.Demo/Pages/IconDemo.axaml.cs
Normal file
45
demo/Semi.Avalonia.Demo/Pages/IconDemo.axaml.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.Primitives;
|
||||
using Avalonia.Controls.Shapes;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.Media;
|
||||
using Avalonia.Threading;
|
||||
|
||||
namespace Semi.Avalonia.Demo.Pages;
|
||||
|
||||
public partial class IconDemo : UserControl
|
||||
{
|
||||
public IconDemo()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
protected override async void OnApplyTemplate(TemplateAppliedEventArgs e)
|
||||
{
|
||||
base.OnApplyTemplate(e);
|
||||
await Dispatcher.UIThread.InvokeAsync(LoadIcons);
|
||||
}
|
||||
|
||||
private void LoadIcons()
|
||||
{
|
||||
IResourceDictionary? resources =
|
||||
AvaloniaXamlLoader.Load(new Uri("avares://Semi.Avalonia/Themes/Shared/Icon.axaml")) as ResourceDictionary;
|
||||
if (resources is null) return;
|
||||
|
||||
var stackPanel = this.FindControl<StackPanel>("IconsPanel");
|
||||
foreach (var key in resources.Keys)
|
||||
{
|
||||
if (resources[key] is not Geometry geometry) continue;
|
||||
var iconControl = new Path
|
||||
{
|
||||
Data = geometry,
|
||||
Fill = Brushes.Black,
|
||||
Width = 48,
|
||||
Height = 48
|
||||
};
|
||||
|
||||
stackPanel?.Children.Add(iconControl);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -104,6 +104,9 @@
|
||||
<TabItem Header="Palette">
|
||||
<pages:PaletteDemo />
|
||||
</TabItem>
|
||||
<TabItem Header="Icon">
|
||||
<pages:IconDemo />
|
||||
</TabItem>
|
||||
<TabItem Header="AutoCompleteBox">
|
||||
<pages:AutoCompleteBoxDemo />
|
||||
</TabItem>
|
||||
|
||||
Reference in New Issue
Block a user