开发者

WPF and control auto size

开发者 https://www.devze.com 2023-02-06 04:39 出处:网络
is it possible that if i put a textbox in border container and will not specify height & width of textbox rather specify height & width for border and textbox will take the size of the border.

is it possible that if i put a textbox in border container and will not specify height & width of textbox rather specify height & width for border and textbox will take the size of the border. how could i do this. i tried开发者_如何学运维 to do it in xaml but fail. need answer. thanks


http://msdn.microsoft.com/en-us/library/system.windows.horizontalalignment.stretch.aspx


It's nice and easy:

<Border Width="200" Height="70" BorderBrush="Black" BorderThickness="2">
  <TextBox></TextBox>
</Border>


<Grid>
   <Border Width="100" Height="100">
      <TextBox />
   </Border>
</Grid>

The text box will be of size of the border.

0

精彩评论

暂无评论...
验证码 换一张
取 消