如何在运行时设置文本并获取TextBlock.ActualHeight [英] How to get TextBlock.ActualHeight with text set at runtime

查看:45
本文介绍了如何在运行时设置文本并获取TextBlock.ActualHeight的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个隐藏的StackPanel,里面有一些TextBlocks.

I have an hidden StackPanel with some TextBlocks inside.


<TextBlock VerticalAlignment="Center" HorizontalAlignment="Right" TextAlignment="Center" TextWrapping="Wrap" FontSize="16" />

推荐答案

小的更新:我显然是通过以下方式解决了此问题:通过命令stckpnl.UpdateLayout()强制进行布局更新;就在读取ActualHeight值之前.

Little update: I apparently solved this issue by forcing a layout update via the command stckpnl.UpdateLayout(); just before the reading of the ActualHeight value.

这是一个好的解决方案吗?

Is this a good solution? Any better solution?

 

此致

FZ


这篇关于如何在运行时设置文本并获取TextBlock.ActualHeight的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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