diff --git a/samples/ControlCatalog/MainWindow.xaml b/samples/ControlCatalog/MainWindow.xaml index ee8706d1e2..28d8346c10 100644 --- a/samples/ControlCatalog/MainWindow.xaml +++ b/samples/ControlCatalog/MainWindow.xaml @@ -5,7 +5,10 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:vm="clr-namespace:ControlCatalog.ViewModels" xmlns:v="clr-namespace:ControlCatalog.Views" - x:Class="ControlCatalog.MainWindow" LocalNotificationManager="{Binding NotificationManager, Mode=OneWayToSource}"> + x:Class="ControlCatalog.MainWindow" + LocalNotificationManager="{Binding NotificationManager, Mode=OneWayToSource}" + NotificationArea.Position="BottomRight" + NotificationArea.MaxItems="3"> diff --git a/src/Avalonia.Controls/Notifications/NotificationArea.cs b/src/Avalonia.Controls/Notifications/NotificationArea.cs index d009ece3a1..3fe9a4a190 100644 --- a/src/Avalonia.Controls/Notifications/NotificationArea.cs +++ b/src/Avalonia.Controls/Notifications/NotificationArea.cs @@ -11,24 +11,44 @@ namespace Avalonia.Controls.Notifications { private IList _items; + public static NotificationPosition GetPosition(TopLevel obj) + { + return obj.GetValue(PositionProperty); + } + + public static void SetPosition(TopLevel obj, NotificationPosition value) + { + obj.SetValue(PositionProperty, value); + } + + public static readonly AvaloniaProperty PositionProperty = + AvaloniaProperty.RegisterAttached("Position", defaultValue: NotificationPosition.TopLeft , inherits: true); + public NotificationPosition Position { - get { return (NotificationPosition)GetValue(PositionProperty); } + get { return GetValue(PositionProperty); } set { SetValue(PositionProperty, value); } } - public static readonly StyledProperty PositionProperty = - AvaloniaProperty.Register(nameof(Position), NotificationPosition.BottomRight); + public static int GetMaxItems(TopLevel obj) + { + return obj.GetValue(MaxItemsProperty); + } + + public static void SetMaxItems(TopLevel obj, int value) + { + obj.SetValue(MaxItemsProperty, value); + } + + public static readonly AvaloniaProperty MaxItemsProperty = + AvaloniaProperty.RegisterAttached("Position", defaultValue: 5, inherits: true); public int MaxItems { - get { return (int)GetValue(MaxItemsProperty); } + get { return GetValue(MaxItemsProperty); } set { SetValue(MaxItemsProperty, value); } } - public static readonly AvaloniaProperty MaxItemsProperty = - AvaloniaProperty.Register(nameof(MaxItems), int.MaxValue); - static NotificationArea() { PseudoClass(PositionProperty, x => x == NotificationPosition.TopLeft, ":topleft");