Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you set Textbox.Width to 100% in silverlight?

How do you set the width of a textbox to fill the container programmatically? For example in xaml if I have the following declaration for the textbox:

<TextBox Height="23"  Name="TextBox1" VerticalAlignment="Top" Width="50" />

how can I set the width so that it fills the container in a button click handler?

like image 258
Carl Rippon Avatar asked Jul 09 '10 15:07

Carl Rippon


1 Answers

You should be able to use HorizontalAlignment="Stretch" (make sure you don't set an explicit Width or MaxWidth to allow dynamic sizing). I haven't done any Sliverlight development, but in WPF, that does the trick!

like image 95
Mark Carpenter Avatar answered Oct 19 '22 07:10

Mark Carpenter