feat: add CopyText to HighContrastDemo.

This commit is contained in:
Zhang Dian
2025-01-21 21:17:20 +08:00
parent 5d0116ca8e
commit b5fe4d92a6
3 changed files with 56 additions and 12 deletions

View File

@@ -1,4 +1,5 @@
using Avalonia.Controls;
using System.Threading.Tasks;
using Avalonia.Controls;
using Semi.Avalonia.Demo.ViewModels;
namespace Semi.Avalonia.Demo.Pages;
@@ -10,4 +11,14 @@ public partial class HighContrastDemo : UserControl
InitializeComponent();
this.DataContext = new HighContrastDemoViewModel();
}
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());
}
}
}