Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个包含一些文本的文本块,但文本总是会改变长度,我需要从这个文本块中渲染一个位图。问题是文本块没有高度、宽度、实际高度、实际宽度或所需大小,因为我将高度和宽度设置为 Double.NaN,因此文本块会自动调整大小。这给我带来了一个问题,因为当我去测量和排列文本块时,我没有任何值。那么有没有办法让我根据文本块内的文本来测量高度和宽度?
这回答了你的问题了吗?
http://blogs.microsoft.co.il/blogs/tamir/archive/2007/03/12/Text-length-measurement_3F00_-It_2700_s-really-easy-with-WPF.aspx