Files
DevToolsAvalonia/常用工具集/Views/MainView.axaml.cs
2025-08-26 08:37:44 +08:00

29 lines
1004 B
C#

using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using Ursa.Controls;
using .Base;
using .ViewModels;
namespace .Views;
public partial class MainView : UserControl
{
public MainView()
{
InitializeComponent();
}
protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
{
base.OnAttachedToVisualTree(e);
var topLevel = TopLevel.GetTopLevel(this);
if (topLevel is null)
return;
GlobalValues.StorageProvider = topLevel?.StorageProvider;
GlobalValues.Clipboard = topLevel.Clipboard;
GlobalValues.NotificationManager = WindowNotificationManager.TryGetNotificationManager(topLevel, out var manager) ? manager : new WindowNotificationManager(topLevel);
GlobalValues.NotificationManager.Position = Avalonia.Controls.Notifications.NotificationPosition.BottomRight;
GlobalValues.NotificationManager.MaxItems = 5;
}
}