[英]How to get the 'Width', when set 'HorizontalAlignment = “Stretch”'?
I had booked a Grid
with HorizontalAlignment = "Stretch"
我已经预订了一个带有
HorizontalAlignment = "Stretch"
的Grid
And now, I want to know what is its Width
? 现在,我想知道它的
Width
多少?
I want to do this by C # at runtime. 我想在运行时用C#做到这一点。
Thanks in advance. 提前致谢。
Let's say that you have the following grid: 假设您具有以下网格:
<Grid Name="gvDummyContent" HorizontalAlignment="Stretch" />
An you want to get the height and width of it. 您想要获取它的高度和宽度。 You can do it like this:
您可以这样做:
double actualWidth = gvDummyContent.ActualWidth;
double actualHeight = gvDummyContent.ActualHeight;
Be sure that you are calling these properties after the controls are loaded. 确保在加载控件后调用这些属性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.