0

该网格的高度是可调整的,我需要能够截断状态一文本,同时保留状态三始终可见且状态二始终显示在状态一正下方的规则。我试图通过将状态 2 的 VerticalAlignment 设置为顶部来实现这一点,但没有运气。

例如,请注意,当您将高度 78 更改为 178 时,状态 2 不再位于状态 1 旁边。

<Grid Height="78"
      Width="167">

<Grid.RowDefinitions>
    <RowDefinition Height="*" />
    <RowDefinition Height="Auto" />
    <RowDefinition Height="Auto" />
</Grid.RowDefinitions>

<Border x:Name="_itemBorder"
        Grid.RowSpan="3"
        Background="LightBlue" />

<TextBlock x:Name="_statusOneTextBlock"
           Grid.Row="0"
           Margin="5"
           Text="STATUS 1 Very long status one text"
           TextWrapping="Wrap"
           TextTrimming="CharacterEllipsis" />

<TextBlock x:Name="_statusTwoTextBlock"
           Grid.Row="1"
           Margin="5"
           Text="STATUS 2"
           VerticalAlignment="Top"
           TextTrimming="CharacterEllipsis" />

<TextBlock x:Name="_statusThreeTextBlock"
           Grid.Row="3"
           Margin="5"
           Text="STATUS 3"
           VerticalAlignment="Bottom"
           TextTrimming="CharacterEllipsis" />
</Grid> 
4

2 回答 2

0
<Grid Height="178" 
  Width="167">

    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition Height="Auto" />
        <RowDefinition Height="Auto" />

    </Grid.RowDefinitions>

    <Border x:Name="_itemBorder" 
    Grid.RowSpan="3" 
    Background="LightBlue" />

    <TextBlock x:Name="_statusOneTextBlock" 
       Grid.Row="0" 
       Margin="5" 
       Text="STATUS 1 Very long status one text" 
       TextWrapping="NoWrap" 
       TextTrimming="CharacterEllipsis" />

    <TextBlock x:Name="_statusTwoTextBlock" 
       Grid.Row="1" 
       Margin="5" 
       Text="STATUS 2" 
       VerticalAlignment="Top" 
       TextTrimming="CharacterEllipsis" />

    <TextBlock x:Name="_statusThreeTextBlock" 
       Grid.Row="2" 
       Margin="5" 
       Text="STATUS 3" 
       VerticalAlignment="Bottom" 
       TextTrimming="CharacterEllipsis" />
</Grid>
于 2012-08-30T02:56:39.380 回答
0

修复了在 TextBlock 中使用 InlineUIContainer:

<Grid Height="68"
      Width="167">

<Grid.RowDefinitions>
    <RowDefinition Height="*" />
    <RowDefinition Height="23" />
</Grid.RowDefinitions>

<Border x:Name="_itemBorder"
        Grid.RowSpan="2"
        Background="LightBlue" />

<TextBlock Grid.Row="0">
<TextBlock x:Name="_statusOneTextBlock"
           Text="STATUS 1 Very long status one text"
           TextWrapping="Wrap"
           TextTrimming="CharacterEllipsis" />
<LineBreak />
<InlineUIContainer>
    <TextBlock x:Name="_statusTwoTextBlock"
               Text="STATUS 2"
               VerticalAlignment="Top"
               TextTrimming="CharacterEllipsis" />
</InlineUIContainer>
</TextBlock>

<TextBlock x:Name="_statusThreeTextBlock"
           Grid.Row="1"
           Text="STATUS 3"
           VerticalAlignment="Bottom"
           TextTrimming="CharacterEllipsis" />
</Grid>
于 2012-08-30T21:50:02.977 回答