WPF设置父(Window) [英] WPF set parent (Window)

查看:1477
本文介绍了WPF设置父(Window)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你怎么当你想它显示为一个对话框中设置一个WPF窗口的父?这两种方法都显示()和ShowDialog的()似乎并没有这样的选择。

How do you set the parent of a WPF window when you want to show it as a dialog? Both methods Show() and ShowDialog() don't seem to have that option.

这在Java中是尽可能您可以通过父在构造函数中。是否有可能在WPF任何方式

This was possible in Java as you could pass the parent in the constructor. Is it possible in any way in WPF?

编辑:
我使用C#

I'm using C#

推荐答案

所有者可以设置,但父母是一个只读属性。

owner can be set but parent is a readonly property.

var w = new Window();
w.Owner = Window.GetWindow(this);
w.Show();

这篇关于WPF设置父(Window)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆