how to calculate the textbock height and width in on load if i create textblock from code?
Call Measure() then Arrange() and then ActualWidth and ActualHeight will be updated.
Call Measure() then Arrange() and then ActualWidth and ActualHeight will be updated.
What are you trying to do that requires you to databind to the ActualWidth property? This is a known issue with Silverlight, and there is no simple workaround. One thing that could be done is to set up the visual tree in such a way that you do not need to actually set the Width … Read more
Width/Height is the requested or layout size. If you set to Auto, then the value is double.NaN when you access the property in code behind. ActualWidth/ActualHeight and RenderSize.Width/RenderSize.Height both return the element’s rendered size, as RenderSize is of type Size. If you want/need the actual size of the item, then use any of these attributes.
ActualHeight and ActualWidth are not set until the control is measured and arranged. Usually there is nothing in InitializeComponent() that causes a measure, so when it returns these will still be zero. You can force these to be computed earlier by simply calling the window’s Measure() and Arrange() methods manually after the window’s InitializeComponent() returns. … Read more