首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 媒体动画 > CAD教程 >

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

2012-12-31 
wpf中grid中的Textbox如何随着grid变宽而变宽呢简单的说就是TextBox随着Grid变化而变化比如Grid x:Name

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>

热点排行