在wpf中在运行时获取网格的高度 [英] get height of grid at runtime in wpf
问题描述
有什么方法可以获取在运行时动态创建的wpf中网格的高度吗?我不想设置网格的固定高度,所以我不设置网格的高度.
我已经尝试过ActualHeight和DesiredSize.Height,但是它无法获得网格的高度.
我已经在xaml文件中声明了一个网格;
< grid name ="grd_Dispaly">
然后在后面的代码中,我动态生成了行和列,并将其添加到网格中.
在网格中添加每一行之后,我要测量网格的高度.
Is there any way to get height of the grid in wpf, created dynamically at run time? I don''t want to set fix height of grid, so i am not set height of grid.
I have already tried for ActualHeight and DesiredSize.Height, but it doesn''t work to get height of the grid.
I have declared one grid in xaml file;
<grid name="grd_Dispaly">
Then in code behind, i have generated rows and columns dynamically and add it in to the grid.
After adding each row in grid, i want to measure height of the grid.
推荐答案
使用ActualWidth和ActualHeight属性来获取大小.
Use the ActualWidth and ActualHeight properties to get the sizes.
这篇关于在wpf中在运行时获取网格的高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!