当前位置: 代码迷 >> Silverlight >> wpf中grid中的Textbox怎么随着grid变宽而变宽呢
  详细解决方案

wpf中grid中的Textbox怎么随着grid变宽而变宽呢

热度:1907   发布时间:2013-02-26 00:00:00.0
wpf中grid中的Textbox如何随着grid变宽而变宽呢
简单的说就是TextBox随着Grid变化而变化
比如
<Grid x:Name="Layoutroot">
        <Grid.RowDefinitions>
            <RowDefinition Height="35"/>
            <RowDefinition Height="25"/>          
            <RowDefinition />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="0.2*"/>
            <ColumnDefinition Width="0.8*" x:Name="MID" />            
        </Grid.ColumnDefinitions>
        <TextBlock Text="日志文件目录" Grid.Row="0" Grid.Column="0" Margin="0 14 0 0 "></TextBlock>
 <TextBox x:Name="txtLogFile" Grid.Row="0" Grid.Column="1" Style="{x:Null}"></TextBox>
</Grid>

让txtLogFile的宽度随着Gird的行变宽而变宽
谢谢大家!
------解决方案--------------------------------------------------------
单纯为了 解决问题 可以把txtLogFile 的  宽度 bingding  到 grid上 
没用编辑器  参考下面的代码  
<TextBox x:Name="txtLogFile" widht="{binding path=AutchWidht ,elementid =Layoutroot}" />
------解决方案--------------------------------------------------------
<Grid x:Name="myGrid">
        <TextBox Text="myTextBox" 
                 HorizontalContentAlignment="Center"
                 VerticalContentAlignment="Center"
                 Foreground="Wheat" 
                 Background="Black"
                 Width="{Binding Path=ActualWidth,ElementName=myGrid}" 
                 Height="{Binding Path=ActualHeight,ElementName=myGrid}"/>
    </Grid>
  相关解决方案