Files
WCS/Cowain.TestProject/Views/MainContextView.axaml.cs
2026-03-02 09:08:20 +08:00

32 lines
1.0 KiB
C#

using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Notifications;
using Avalonia.LogicalTree;
using Cowain.Base.Helpers;
using WindowNotificationManager = Ursa.Controls.WindowNotificationManager;
namespace Cowain.TestProject.Views;
public partial class MainContextView : UserControl
{
public MainContextView()
{
InitializeComponent();
}
protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
{
base.OnAttachedToVisualTree(e);
var topLevel = TopLevel.GetTopLevel(this);
FileDialogHelper.Provider = topLevel?.StorageProvider;
NotificationHelper.NotificationManager = new WindowNotificationManager(topLevel) { MaxItems = 3 };
NotificationHelper.NotificationManager.Position = NotificationPosition.BottomRight;
}
protected override void OnDetachedFromLogicalTree(LogicalTreeAttachmentEventArgs e)
{
base.OnDetachedFromLogicalTree(e);
FileDialogHelper.Provider = null;
NotificationHelper.NotificationManager?.Uninstall();
}
}