feat: add default NotificationCard icon.

This commit is contained in:
Zhang Dian 2023-10-09 14:56:40 +08:00
parent ce2e104286
commit 72f8d51eb1
3 changed files with 9 additions and 8 deletions

View File

@ -8,6 +8,7 @@
d:DesignWidth="800"
mc:Ignorable="d">
<StackPanel HorizontalAlignment="Left" Spacing="20">
<Button Click="InfoButton_OnClick" Content="Default" />
<Button Click="InfoButton_OnClick" Content="Information" />
<Button Click="InfoButton_OnClick" Content="Success" />
<Button Click="InfoButton_OnClick" Content="Warning" />

View File

@ -2,17 +2,14 @@ using System;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Notifications;
using Avalonia.Controls.Presenters;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
using Avalonia.VisualTree;
using Semi.Avalonia.Demo.Views;
namespace Semi.Avalonia.Demo.Pages;
public partial class NotificationDemo : UserControl
{
private WindowNotificationManager? _manager;
public NotificationDemo()
{
InitializeComponent();
@ -22,14 +19,16 @@ public partial class NotificationDemo : UserControl
{
base.OnAttachedToVisualTree(e);
var topLevel = TopLevel.GetTopLevel(this);
_manager = new WindowNotificationManager(topLevel){ MaxItems = 3};
_manager = new WindowNotificationManager(topLevel) { MaxItems = 3 };
}
private void InfoButton_OnClick(object? sender, RoutedEventArgs e)
{
if (sender is Button b && b.Content is string s && Enum.TryParse<NotificationType>(s, out NotificationType t))
if (sender is Button b && b.Content is string s)
{
_manager?.Show(new Notification(t.ToString(), "This is message", t));
_manager?.Show(Enum.TryParse<NotificationType>(s, out NotificationType t)
? new Notification(t.ToString(), "This is message", t)
: new Notification(s, "This is message"));
}
}
}

View File

@ -37,7 +37,8 @@
Height="16"
Margin="16,16,12,0"
VerticalAlignment="Top"
IsVisible="False" />
IsVisible="False"
Data="{DynamicResource NotificationCardInformationIconPathData}"/>
<ContentControl
Name="PART_Content"
MinHeight="64"