Closed kikipoulet closed 1 year ago
Hello, @kikipoulet
It's quite a complex task, as far as I can see. Because, for example, your dialog is at least not straight down, it has a vertical indent from the bottom. I'll think about how to implement it better.
For now, I'm thinking about the idea of allowing you to create your own Positioner
Would be great honestly! If I can change the positioner of the dialog control with a (binded) property it would be absolutely perfect :)
Seems like this is working fine - i added a configurable PopupPositioner
and implemented AlignmentDialogPopupPositioner
which can handle Horizontal and Vertical alignment and also Margin out of the box!
Absolutely awesome ! Thank you for the feature !
It is marked as preview version now, cuz i want to implement some features.
<dialogHostAvalonia:DialogHost x:Name="dialogHost" Identifier="MainDialogHost" OverlayBackground="Transparent"
DialogMargin="0" DisableOpeningAnimation="True"
dialogHostAvalonia:DialogHostStyle.CornerRadius="10">
</dialogHostAvalonia:DialogHost>
dialogHost.PopupPositioner = new AlignmentDialogPopupPositioner()
{
VerticalAlignment = VerticalAlignment.Top,
HorizontalAlignment = HorizontalAlignment.Left,
// Margin = new Thickness(x <5? 5: x, y <5?5:y)
Margin = new Thickness(20)
};
DialogHost.Show(_startDevice, "MainDialogHost");
When I control it in C#, it doesn't seem to take effect, and the pop-up user control always appears in the upper left corner.
<dialogHostAvalonia:DialogHost x:Name="dialogHost" Identifier="MainDialogHost" OverlayBackground="Transparent" DialogMargin="0" DisableOpeningAnimation="True" dialogHostAvalonia:DialogHostStyle.CornerRadius="10"> </dialogHostAvalonia:DialogHost>
dialogHost.PopupPositioner = new AlignmentDialogPopupPositioner() { VerticalAlignment = VerticalAlignment.Top, HorizontalAlignment = HorizontalAlignment.Left, // Margin = new Thickness(x <5? 5: x, y <5?5:y) Margin = new Thickness(20) }; DialogHost.Show(_startDevice, "MainDialogHost");
When I control it in C#, it doesn't seem to take effect, and the pop-up user control always appears in the upper left corner.
In your C# sample your VerticalAlignment property seems to be Top and your HorizontalAlignment property is Left so it works correctly.
Maybe check in your code if your values are correct or not 👍
But I set the margin to 20, hoping that the pop-up window will be 20 away from the top and left margins, but the current top and left margins are 0. Is my understanding of the Margin property wrong? thank you for your reply!
Maybe try removing the property DialogMargin="0", maybe it overrides the dialogpopuppositioner margin ?
Hello, @kevin100702
It kikipoulet suggestion doesn't help, please, open a new issue for that. Thanks
I use DialogHost in my SukiUI library to show dialogs, and by the way thank you for you work 👍 Recently I made some Mobile Controls which requires to show a dialog at the bottom :
https://github.com/kikipoulet/SukiUI/wiki/3.-Mobile-Controls#mobile-picker
To make that I used some very ugly code in a very ugly fork to create a new parameter and simply show the dialog at bottom with this code change :
var verticalMargin = (parameters.AnchorRectangle.Height - parameters.Size.Height) / 1.05;
in the DialogPopupPositioner class. The problem is that it messed up all my dependencies with avalonia 0.10 to 0.11 migration, and the only solution for me was to come at the DialogHost 0.6.0 nuget package, which basically saved me 👍
So .. could it be possible to add a "VerticalAlignment" parameter in the dialoghost control ? :-)