0

我有什么:

<Grid HorizontalAligment="Stretch">
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto" />
        <ColumnDefinition Width="16" />
    </Grid.ColumnDefinitions>
  <TextBlock Text="Text" Grid.Column="0" />
  <Grid Background="Black" VerticalAligment="Stretch" Grid.Column="1">
    <TextBlock Text="*" />
  </Grid>
</Grid>

结果:

__________
|        |
|Text *  |
|________|

我有一个问题:当文本太宽时,*会离开屏幕。

__________
|        |
|long Tex|t *
|________|

那么,如果它离开屏幕,如何指定*应该覆盖部分?Text

__________
|        |
|long Te*|t
|________|

第二个问题:我不能使用 MaxWidth Text,因为Grid它具有动态宽度。

UPD:如果我将Width="*"用于第一列,我会得到这个:

__________
|        |
|Text   *|
|________|
4

1 回答 1

0

使用以下

<ColumnDefinition Width="*" />

代替

<ColumnDefinition Width="Auto" />

编辑:这是完整的代码:

<Grid >
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="16" />
        </Grid.ColumnDefinitions>

        <TextBlock Text="123 Text Long. Really Text Long. Really Text Long. Really Text Long. Really Text Long. Really Text Long. Really Text Long. Really 
                   Text Long. Really Text Long. Really Text Long. Really Text Long. Really Text Long. Really Text Long. Really Text Long. Really Text Long. Really 
                   Text Long. Really Text Long. Really Text Long. Really Text Long. Really Text Long. Really Text Long. Really 
                   " Grid.Column="0"/>
        <Grid Grid.Column="1">
                <TextBlock Text="*" />
            </Grid>
    </Grid>

输出如下。123是正文的开始。这不是你所期待的吗?

输出

于 2012-09-11T01:28:17.867 回答