A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
To ensure your popup closes from the center, you need to adjust the AnchorX and AnchorY properties before starting the exit animation. It looks like you're on the right track. Just make sure you're setting those anchors to 0.5 for both axes. Here’s a revised version of your exit animation method:
private static async Task ExitAnimation(Popup popup) {
if (popup.Content is VisualElement popUpBorder) {
// Set the anchor to the center
popUpBorder.AnchorX = 0.5;
popUpBorder.AnchorY = 0.5;
// Optionally reset scale and opacity before starting the animation
popUpBorder.Scale = 1;
popUpBorder.Opacity = 1;
await Task.WhenAll(new Task[]
{
popUpBorder.ScaleTo(0.5, 500, Easing.CubicInOut),
popUpBorder.FadeTo(0, 500, Easing.CubicInOut)
});
popup.Close();
}
}