c# – 当用户更改对话框的大小时,如何设置wpf文本框以自动调整大小?

用户更改对话框的大小时,如何设置wpf文本框以自动调整大小?
<Window x:Class="MemoPad.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Background="LightGray" 
    Title="Window1" Height="350" Width="700" >
<StackPanel Orientation="Vertical">
    <Menu DockPanel.Dock ="Right">
        <MenuItem Header="Find" x:Name="gMNuFind" />
    </Menu>
    <Button Content=" Find " 
          Margin="5,10,5,5"
          x:Name="gBuFind" 
          />
    <TextBox Margin="0,0"
          HorizontalAlignment="Left"
          VerticalAlignment="Top" 
          MinHeight="270" MinWidth="690"                  
          x:Name = "gTBxInfo" 
          textwrapping="Wrap"
          AcceptsReturn="True"
          ScrollViewer.VerticalScrollBarVisibility="Auto" 
          />
</StackPanel>

解决方法

或者将StackPanel更改为Grid
<Window x:Class="WpfApplication1.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Background="LightGray" 
    Title="Window1" Height="350" Width="700" >
    <Grid>
        <Grid.RowDeFinitions>
            <RowDeFinition Height="auto" />
            <RowDeFinition Height="auto" />
            <RowDeFinition Height="1*" />
        </Grid.RowDeFinitions>
        <Menu>
            <MenuItem Header="Find" x:Name="gMNuFind" />
        </Menu>
        <Button Grid.Row="1" Content=" Find " 
          Margin="5,5"
          x:Name="gBuFind" 
          />
        <TextBox Grid.Row="2" Margin="0,0"
          HorizontalAlignment="Stretch"
          VerticalAlignment="Stretch" 
          MinHeight="270" MinWidth="690"                  
          x:Name = "gTBxInfo" 
          textwrapping="Wrap"
          AcceptsReturn="True"
          ScrollViewer.VerticalScrollBarVisibility="Auto" 
          />
    </Grid>
</Window>

相关文章

在要实现单例模式的类当中添加如下代码:实例化的时候:frmC...
1、如果制作圆角窗体,窗体先继承DOTNETBAR的:public parti...
根据网上资料,自己很粗略的实现了一个winform搜索提示,但是...
近期在做DSOFramer这个控件,打算自己弄一个自定义控件来封装...
今天玩了一把WMI,查询了一下电脑的硬件信息,感觉很多代码都...
最近在研究WinWordControl这个控件,因为上级要求在系统里,...