【问题标题】:How can I set the percentage width of a text box in a singular column grid如何在单个列网格中设置文本框的百分比宽度
【发布时间】:2015-04-20 05:52:29
【问题描述】:

除了我在下面创建的 hack 之外,还有什么方法可以在单个列网格中设置文本框的百分比宽度?由于这个解决方案看起来很混乱,因为我需要设置两列,一列用于控制,另一列用于剩余空间。

 <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="30"/>
            </Grid.RowDefinitions>
            <Grid Grid.Column="0" Grid.Row="0" Background="Red">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width=".8*"/>
                    <ColumnDefinition Width=".2*"/>
                </Grid.ColumnDefinitions>
                <TextBox Grid.Column="0" Background="Gray" Text="Hello world" Foreground="Black"/>
            </Grid>
        </Grid>

【问题讨论】:

    标签: c# wpf windows-store


    【解决方案1】:

    你是对的。这是确保您的 TextBox 是包含列宽度的 80% 的唯一方法。

    【讨论】:

      猜你喜欢
      • 2018-05-04
      • 1970-01-01
      • 1970-01-01
      • 2016-08-20
      • 2012-01-17
      • 2013-05-25
      • 2013-03-24
      • 2012-10-03
      相关资源
      最近更新 更多