I would like to open a new WPF window on top of the parent window, or at least where the mouse is. I can receive the correct mouse coordinates, but it does not update the Left and Top attribute correctly, means no effect but it works when I use hard-coded coordinates
this.Left = System.Windows.Input.Mouse.GetPosition(null).X;
this.Top = System.Windows.Input.Mouse.GetPosition(null).Y;
So I try to use WindowStartupLocation="CenterOwner" in the WPF, but I do not know how to set the parent WPF in MvvmCross. I call the child window like this by the parent ViewModel:
ShowChildCommand = new MvxAsyncCommand(async () => await NavigationService.Navigate<ChildViewModel>());
but it does not supply any option to set a parent. My child WPF class looks this:
using MvvmCross.Platforms.Wpf.Presenters.Attributes;
namespace test.wpf.Views
{
[MvxWindowPresentation(Identifier = nameof(ChildView), Modal = false)]
public partial class GroupMembershipView
{
public ChildView()
{
InitializeComponent();
}
}
}
Besides I tried to figure out how to set it maybe in WPF itself:
Owner="{x:Static test.wpf:App.CurrentMainWindow}
But no success. What is the correct way to define the parent, or just set the new WPF window on top in MvvmCross?
I think I missed something one following post: How to set window's owner to MainWindow through XAML in WPF?
so, I added the mentioned function to my App.xaml.cs
public static MvxWindow CurrentMainWindow
{
get { return (MvxWindow)Current.MainWindow; }
}
and in the WPF like mentioned in the post:
xmlns:test.wpf="clr-namespace:test.wpf"
WindowStartupLocation="CenterOwner" Owner="{x:Static test.wpf:App.CurrentMainWindow}"