diff --git a/DialogHost.Avalonia/DialogHost.axaml b/DialogHost.Avalonia/DialogHost.axaml index a86a258..d6f1547 100644 --- a/DialogHost.Avalonia/DialogHost.axaml +++ b/DialogHost.Avalonia/DialogHost.axaml @@ -32,11 +32,12 @@ - + VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" + Tag="{TemplateBinding BlurBackgroundRadius}"/> @@ -44,13 +45,6 @@ - @@ -73,14 +67,25 @@ - + + + + + \ No newline at end of file diff --git a/DialogHost.Avalonia/DialogHost.axaml.cs b/DialogHost.Avalonia/DialogHost.axaml.cs index d99172f..a17fc36 100644 --- a/DialogHost.Avalonia/DialogHost.axaml.cs +++ b/DialogHost.Avalonia/DialogHost.axaml.cs @@ -31,6 +31,8 @@ public class DialogHost : ContentControl { /// public const string DialogHostRoot = "PART_DialogHostRoot"; + private const double DefaultBlurRadius = 16.0; + /// /// Tracks all loaded instances of DialogHost. /// @@ -175,6 +177,18 @@ public class DialogHost : ContentControl { (o, v) => o.PopupPositioner = v, defaultBindingMode: BindingMode.TwoWay); + /// + /// Identifies the property. + /// + public static readonly StyledProperty BlurBackgroundProperty + = AvaloniaProperty.Register(nameof(BlurBackground)); + + /// + /// Identifies the property. + /// + public static readonly StyledProperty BlurBackgroundRadiusProperty + = AvaloniaProperty.Register(nameof(BlurBackgroundRadius), DefaultBlurRadius); + private DialogClosingEventHandler? _asyncShowClosingEventHandler; private DialogOpenedEventHandler? _asyncShowOpenedEventHandler; @@ -327,6 +341,22 @@ public IDialogPopupPositioner? PopupPositioner { get => _popupPositioner; set => SetAndRaise(PopupPositionerProperty, ref _popupPositioner, value); } + + /// + /// Gets or sets whether to enable background blur when dialog is opened + /// + public bool BlurBackground { + get => GetValue(BlurBackgroundProperty); + set => SetValue(BlurBackgroundProperty, value); + } + + /// + /// Gets or sets radius of background blur when is enabled + /// + public double BlurBackgroundRadius { + get => GetValue(BlurBackgroundRadiusProperty); + set => SetValue(BlurBackgroundRadiusProperty, value); + } /// /// Returns a DialogSession for the currently open dialog for managing it programmatically. If no dialog is open, CurrentSession will return null diff --git a/DialogHost.Demo/Views/FruitBowl.axaml b/DialogHost.Demo/Views/FruitBowl.axaml index cc7453b..2a9602e 100644 --- a/DialogHost.Demo/Views/FruitBowl.axaml +++ b/DialogHost.Demo/Views/FruitBowl.axaml @@ -5,7 +5,7 @@ xmlns:dialogHostAvalonia="clr-namespace:DialogHostAvalonia;assembly=DialogHost.Avalonia" xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" - MinHeight="256" MinWidth="256" + MinHeight="250" MinWidth="250" x:Class="DialogHostDemo.Views.FruitBowl"> diff --git a/DialogHost.Demo/Views/MainWindow.axaml b/DialogHost.Demo/Views/MainWindow.axaml index 929eeb2..12a7e48 100644 --- a/DialogHost.Demo/Views/MainWindow.axaml +++ b/DialogHost.Demo/Views/MainWindow.axaml @@ -9,8 +9,8 @@ mc:Ignorable="d" x:Class="DialogHostDemo.Views.MainWindow" Icon="/Assets/avalonia-logo.ico" - Width="820" Height="420" - MinWidth="820" MinHeight="420" + Width="1024" Height="420" + MinWidth="1024" MinHeight="420" Title="DialogHost.Demo"> @@ -33,14 +33,14 @@ SAMPLE 1: Localized dialog encapsulating specific content, launched from a routed command, response handled in code-behind. @@ -70,6 +70,28 @@ + + + SAMPLE 4: Dialog with blur. + Blur can be controlled via BlurBackground and BlurBackgroundRadius properties. + + + + + Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas sed metus semper, faucibus erat ac, tincidunt odio. Donec congue nisi purus, non consectetur purus sollicitudin sed. Suspendisse iaculis dictum porttitor. Nulla ex leo, pulvinar venenatis arcu in, luctus efficitur nisl. Mauris non velit quis elit placerat auctor porttitor ac augue. Phasellus ut ipsum enim. Proin interdum aliquam ex sed laoreet. Sed eros nulla, ornare elementum urna vel, fringilla pharetra lorem. Integer hendrerit eros a tortor gravida, in lacinia augue blandit. Donec dignissim dapibus augue vel ultricies. Donec in velit mi. Pellentesque ac lorem vitae magna ullamcorper vehicula. + + + + + + diff --git a/DialogHost.Demo/Views/MainWindow.axaml.cs b/DialogHost.Demo/Views/MainWindow.axaml.cs index 40a90e4..65855af 100644 --- a/DialogHost.Demo/Views/MainWindow.axaml.cs +++ b/DialogHost.Demo/Views/MainWindow.axaml.cs @@ -31,4 +31,8 @@ private async void OpenDialogWithModel(object? sender, RoutedEventArgs e) { private async void OpenNoAnimationDialog(object? sender, RoutedEventArgs e) { await DialogHost.Show(Resources["Sample2View"]!, "NoAnimationDialogHost"); } + + private async void OpenBlurDialog(object? sender, RoutedEventArgs e) { + await DialogHost.Show(Resources["Sample2View"]!, "BlurDialogHost"); + } } \ No newline at end of file