Using Measure to calculate size of a TextBlock


in wpf have been using code similar following size of textblock when wraps text within given size of box. go on position text relative other objects before rendering.

mytextblock.maxwidth = boxsize.width*0.9;
mytextblock.maxheight = boxsize.height*0.9;
mytextblock.measure(boxsize);
size textblocksize = mytextblock.desiredsize;

in silverlight desiredsize returns zero.  is expected , there can size of a textblock before rendered?

thanks

nick 

 

yeah, actualwidth/actualheight after setting text properties:

    mytextblock.maxwidth = boxsize.width*0.9;
    mytextblock.maxheight = boxsize.height*0.9;
    mytextblock.font*** = xxxx
    mytextblock.text = ...

    size textblocksize = new size(mytextblock.actualwidth, mytextblock.actualheight);

-mark
silverlight program manager
microsoft
post provided "as-is"



Silverlight  >  Programming Silverlight with .NET – General



Comments

Popular posts from this blog

Conditional formatting a graph vertical axis in SSRS 2012 charts

Register with Power BI failed

SQL server replication error Cannot find the dbo or user defined function........