Make auto text block width

How to set the height and width of a dynamically created text block in auto?

TextBlock myTextBlock = new TextBlock() { Text = "Text Block", Width = 140, Height = 40, FontSize = 20 }; 
+6
source share
1 answer

The installation width (or height) to Double.NaN equivalent to setting the width to auto in XAML.

 TextBlock myTextBlock = new TextBlock() { Text = "Text Block", Width = Double.NaN, Height = Double.NaN, FontSize = 20 }; 

Also see MSDN

+5
source

All Articles