WPF用户控制父级
我有一个MainWindow在运行时加载到的用户控件。我无法从中获取包含窗口的句柄UserControl。 我已经尝试过this.Parent,但是它始终为null。有谁知道如何从WPF中的用户控件获取包含窗口的句柄? 这是控件的加载方式: private void XMLLogViewer_MenuItem_Click(object sender, RoutedEventArgs e) { MenuItem application = sender as MenuItem; string parameter = application.CommandParameter as string; string controlName = parameter; if (uxPanel.Children.Count == 0) { System.Runtime.Remoting.ObjectHandle instance = Activator.CreateInstance(Assembly.GetExecutingAssembly().FullName, controlName); UserControl control = instance.Unwrap() as UserControl; this.LoadControl(control); } } private void LoadControl(UserControl control) { …