C# 左键单击WPF web应用程序上下文菜单

C# 左键单击WPF web应用程序上下文菜单,c#,wpf,web,uwp-xaml,xbap,C#,Wpf,Web,Uwp Xaml,Xbap,我遇到了一个非常奇怪的问题。我想打开一个上下文菜单左键点击一个按钮。。。这是我的解决方案,但它引发System.ComponentModel.Win32Exception public class ButtonKontext : System.Windows.Controls.Button { public ButtonKontext() { this.Click += new System.Windows.RoutedEventHandler(this.Butt

我遇到了一个非常奇怪的问题。我想打开一个上下文菜单左键点击一个按钮。。。这是我的解决方案,但它引发System.ComponentModel.Win32Exception

public class ButtonKontext : System.Windows.Controls.Button
{
    public ButtonKontext()
    {
        this.Click += new System.Windows.RoutedEventHandler(this.Button_Click_1);

    }

    public void Button_Click_1(object sender, RoutedEventArgs e)
    {
        if (this.ContextMenu != null)
        {
            //ContextMenu contextMenu = this.ContextMenu;
            //this.ContextMenu.PlacementTarget = this;
            this.ContextMenu.IsOpen = true;  // System.ComponentModel.Win32Exception here
        }
    }
}
System.ComponentModel.Win32异常:“在obersten Ebene erstellt werden的obersten中没有任何异常” -->编辑:无法在顶层创建子窗口–Thx Jimenemex用于正确翻译


问题是,如果我右键单击按钮,contextmenu将正常显示。那么这里的问题是什么?有什么想法吗?

在正常的wpf(.exe)上,问题不仅仅存在于wpf(xbap)上。
在微软推出xbap后,无法在顶层创建子窗口,互联网本身转向了HTML5,不再需要将WPF或Silverlight注入web浏览器。现在微软正在做Blazor实验,