WPF - setting HorizontalAlignment= Stretch to Textbox in StackPanel

后端 未结 3 1770
一向
一向 2021-02-19 08:20

Why doesn\'t a textbox stretch to fill space in a stackpanel? Is this by design? In a grid, the textbox stretches as expected.

3条回答
  •  被撕碎了的回忆
    2021-02-19 08:24

    Yes, it's by design. The StackPanel will allocate the space the TextBox asks for. If you haven't set a width on the TextBox, it will require only enough width to fit its text.

提交回复
热议问题