Browse Source

feat: WindowNotificationManager: support TopCenter and BottomCenter position (#12804)

* feat: support topcenter and bottom center.

* fix: fix typo.
pull/12445/head
Dong Bin 2 years ago
committed by GitHub
parent
commit
db7cbaa61d
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      src/Avalonia.Controls/Notifications/NotificationPosition.cs
  2. 4
      src/Avalonia.Controls/Notifications/WindowNotificationManager.cs
  3. 11
      src/Avalonia.Themes.Fluent/Controls/WindowNotificationManager.xaml
  4. 11
      src/Avalonia.Themes.Simple/Controls/WindowNotificationManager.xaml

4
src/Avalonia.Controls/Notifications/NotificationPosition.cs

@ -9,6 +9,8 @@
TopLeft,
TopRight,
BottomLeft,
BottomRight
BottomRight,
TopCenter,
BottomCenter,
}
}

4
src/Avalonia.Controls/Notifications/WindowNotificationManager.cs

@ -15,7 +15,7 @@ namespace Avalonia.Controls.Notifications
/// An <see cref="INotificationManager"/> that displays notifications in a <see cref="Window"/>.
/// </summary>
[TemplatePart("PART_Items", typeof(Panel))]
[PseudoClasses(":topleft", ":topright", ":bottomleft", ":bottomright")]
[PseudoClasses(":topleft", ":topright", ":bottomleft", ":bottomright", ":topcenter", ":bottomcenter")]
public class WindowNotificationManager : TemplatedControl, IManagedNotificationManager
{
private IList? _items;
@ -215,6 +215,8 @@ namespace Avalonia.Controls.Notifications
PseudoClasses.Set(":topright", position == NotificationPosition.TopRight);
PseudoClasses.Set(":bottomleft", position == NotificationPosition.BottomLeft);
PseudoClasses.Set(":bottomright", position == NotificationPosition.BottomRight);
PseudoClasses.Set(":topcenter", position == NotificationPosition.TopCenter);
PseudoClasses.Set(":bottomcenter", position == NotificationPosition.BottomCenter);
}
}
}

11
src/Avalonia.Themes.Fluent/Controls/WindowNotificationManager.xaml

@ -42,6 +42,11 @@
<Setter Property="HorizontalAlignment" Value="Right" />
</Style>
<Style Selector="^:topcenter /template/ ReversibleStackPanel#PART_Items">
<Setter Property="VerticalAlignment" Value="Top" />
<Setter Property="HorizontalAlignment" Value="Center" />
</Style>
<Style Selector="^:bottomleft /template/ ReversibleStackPanel#PART_Items">
<Setter Property="ReverseOrder" Value="True" />
<Setter Property="VerticalAlignment" Value="Bottom" />
@ -53,5 +58,11 @@
<Setter Property="VerticalAlignment" Value="Bottom" />
<Setter Property="HorizontalAlignment" Value="Right" />
</Style>
<Style Selector="^:bottomcenter /template/ ReversibleStackPanel#PART_Items">
<Setter Property="ReverseOrder" Value="True" />
<Setter Property="VerticalAlignment" Value="Bottom" />
<Setter Property="HorizontalAlignment" Value="Center" />
</Style>
</ControlTheme>
</ResourceDictionary>

11
src/Avalonia.Themes.Simple/Controls/WindowNotificationManager.xaml

@ -38,6 +38,11 @@
<Setter Property="HorizontalAlignment" Value="Right" />
</Style>
<Style Selector="^:topcenter /template/ ReversibleStackPanel#PART_Items">
<Setter Property="VerticalAlignment" Value="Top" />
<Setter Property="HorizontalAlignment" Value="Center" />
</Style>
<Style Selector="^:bottomleft /template/ ReversibleStackPanel#PART_Items">
<Setter Property="ReverseOrder" Value="True" />
<Setter Property="VerticalAlignment" Value="Bottom" />
@ -49,5 +54,11 @@
<Setter Property="VerticalAlignment" Value="Bottom" />
<Setter Property="HorizontalAlignment" Value="Right" />
</Style>
<Style Selector="^:bottomcenter /template/ ReversibleStackPanel#PART_Items">
<Setter Property="ReverseOrder" Value="True" />
<Setter Property="VerticalAlignment" Value="Bottom" />
<Setter Property="HorizontalAlignment" Value="Center" />
</Style>
</ControlTheme>
</ResourceDictionary>

Loading…
Cancel
Save