在wpf画布控件中添加时如何获取动态设计的用户控件的高度和宽度? [英] How to get height and width of dynamically designed user control while added in wpf canvas control?

查看:73
本文介绍了在wpf画布控件中添加时如何获取动态设计的用户控件的高度和宽度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在开发一个 wpf 应用程序.我正在画布中添加 myUserControl 的对象.我需要高度和添加的用户控件.现在的问题是用户控件是动态设计的,我正在创建网格并根据用户配置添加行和列,并且我在高度和宽度上给出自动.所以我在画布中添加它时没有得到用户控件的实际高度和宽度.

Hello I am developing one wpf application. I am adding object of myUserControl in canvas. i need height and with of added usercontrol. Now problem is that user control is design dynamically, i am creating grid and adding row and column according to configured by user, and i am giving auto in height and width. so i am not getting actual height and width of user control while adding it in canvas.

推荐答案

所有从 FrameworkElement 派生的 UI 元素都有 ActualWidthActualHeight 属性.

All UI elements derived from FrameworkElement have the ActualWidth and ActualHeight properties.

这篇关于在wpf画布控件中添加时如何获取动态设计的用户控件的高度和宽度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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