Child WPF 在 parent WPF 之上(MvvmCross)

Child WPF on top of parent WPF (MvvmCross)

我想在 parent window 或至少鼠标所在的位置打开一个新的 WPF window。 我可以接收到正确的鼠标坐标,但它没有正确更新 Left 和 Top 属性,这意味着没有效果,但是当我使用 hard-coded 坐标

时它起作用了
this.Left = System.Windows.Input.Mouse.GetPosition(null).X;
this.Top = System.Windows.Input.Mouse.GetPosition(null).Y;

所以我尝试在WPF中使用WindowStartupLocation="CenterOwner",但我不知道如何在MvvmCross中设置parent WPF。 我通过 parent ViewModel:

这样调用 child window
ShowChildCommand = new MvxAsyncCommand(async () => await NavigationService.Navigate<ChildViewModel>());

但它不提供任何设置 parent 的选项。我的 child WPF class 看起来是这样的:

using MvvmCross.Platforms.Wpf.Presenters.Attributes;

namespace test.wpf.Views
{
    [MvxWindowPresentation(Identifier = nameof(ChildView), Modal = false)]
    public partial class GroupMembershipView
    {
        public ChildView()
        {
            InitializeComponent();
        }

    }

}

此外,我试图弄清楚如何在 WPF 本身中设置它:

Owner="{x:Static test.wpf:App.CurrentMainWindow}

但是没有成功。 定义 parent 的正确方法是什么,或者只是在 MvvmCross 中将新的 WPF window 设置在顶部?

我想我错过了以下内容post:

所以,我将提到的功能添加到我的 App.xaml.cs

public static MvxWindow CurrentMainWindow
{
    get { return (MvxWindow)Current.MainWindow; }
}

并且在 post 中提到的 WPF 中:

xmlns:test.wpf="clr-namespace:test.wpf"
WindowStartupLocation="CenterOwner" Owner="{x:Static test.wpf:App.CurrentMainWindow}"