我有什么:
<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
|________|
的一部分?
Text
第二个问题:我无法对Grid
使用MaxWidth,因为Width="*"
具有动态宽度。
UPD :如果我在第一列使用__________
| |
|Text *|
|________|
,我会得到这个:
{{1}}
答案 0 :(得分: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是文本的开头。这不是你所期待的吗?