如何在WPF中获取父窗口的高度和宽度 [英] How to get height and width of parent window in WPF

查看:2016
本文介绍了如何在WPF中获取父窗口的高度和宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用ITabbedMDI界面将窗口设计与Windows窗体中的Mdi容器相同。因此,如果父窗口最大化,如何更改子窗口的高度和宽度并保持与父窗口相同。我已经将子窗口作为用户控件,谢谢。

I made window design same as Mdi container in windows form using ITabbedMDI interface. So how can I change height and width of child window and keep same as parent window if parent window is maximized. I had made child window as user control, Thanks.

推荐答案

您可以使用绑定。就像在这个例子中一样:

You can use binding for this. Like in this example:
var height = new Binding("ActualHeight") { Source = MdiContainer };
var width = new Binding("ActualWidth") {Source = MdiContainer};
child.SetBinding(FrameworkElement.WidthProperty, width);
child.SetBinding(FrameworkElement.HeightProperty, height);


这篇关于如何在WPF中获取父窗口的高度和宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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