mirror of
https://gitcode.com/gh_mirrors/se/Semi.Avalonia
synced 2026-04-25 10:56:35 +08:00
* feat: enhance navigation and UI structure in MainView and Application. * feat: implement singleton pattern for PaletteDemoViewModel and add initialization check * feat: set FontWeight to Normal for navigation button in MainView --------- Co-authored-by: Dong Bin <popmessiah@hotmail.com>
37 lines
960 B
C#
37 lines
960 B
C#
using System.Threading.Tasks;
|
|
using Avalonia.Controls;
|
|
using Avalonia.Controls.Primitives;
|
|
using Avalonia.Input.Platform;
|
|
using Avalonia.Threading;
|
|
using Semi.Avalonia.Demo.ViewModels;
|
|
|
|
namespace Semi.Avalonia.Demo.Pages;
|
|
|
|
public partial class PaletteDemo : UserControl
|
|
{
|
|
public PaletteDemo()
|
|
{
|
|
InitializeComponent();
|
|
this.DataContext = PaletteDemoViewModel.Instance.Value;
|
|
}
|
|
|
|
protected override async void OnApplyTemplate(TemplateAppliedEventArgs e)
|
|
{
|
|
base.OnApplyTemplate(e);
|
|
if (this.DataContext is PaletteDemoViewModel vm && !vm.IsInitialized)
|
|
{
|
|
await Dispatcher.UIThread.InvokeAsync(() => { vm?.InitializeResources(); });
|
|
}
|
|
}
|
|
|
|
public async Task Copy(object? o)
|
|
{
|
|
if (o is null) return;
|
|
var toplevel = TopLevel.GetTopLevel(this);
|
|
if (toplevel?.Clipboard is { } c)
|
|
{
|
|
await c.SetTextAsync(o.ToString());
|
|
}
|
|
}
|
|
}
|