4

Does anyone know how to set the TextBox.Width property to fill up the remainder of the parent container in code? In Xaml, I would simply set the Width property to *, but I can't figure out how to do this in code.

Thanks, Roy

2 Answers 2

8

Are you looking for

HorizontalAlignment="Stretch"

Related answers:

WPF - setting HorizontalAlignment= Stretch to Textbox in StackPanel

HorizontalAlignment=Stretch, MaxWidth, and Left aligned at the same time?

Sign up to request clarification or add additional context in comments.

Comments

4

Try the following

textBox.Width = Double.NaN;

Double.NaN (not a number) is the equivalent of any size.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.