1

請幫我理解背後的問題,它的修復,我遇到了麻煩,得到我想要的文本顯示行爲。Silverlight切斷文本/包裝它並顯示不正確

對於TextBlock環繞的特定長度的字符串,但不更新控件以顯示第二行,實際上使部分文本消失。

這工作正常XamlPad,但不是在Silverlight 3和Expression Blend 3

<Grid x:Name="LayoutRoot" Background="{x:Null}"> 
    <Grid.RowDefinitions> 
     <RowDefinition Height="Auto"/> 
     <RowDefinition Height="Auto"/> 
    </Grid.RowDefinitions> 
    <Grid.ColumnDefinitions> 
     <ColumnDefinition Width="Auto"/> 
     <ColumnDefinition Width="Auto"/> 
    </Grid.ColumnDefinitions> 
<Border CornerRadius="20,20,20,20" Grid.ColumnSpan="2" Grid.RowSpan="2" BorderBrush="#FF000000" BorderThickness="1,1,1,1"> 
    <Border.Background> 
     <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> 
      <GradientStop Color="#FF2100FF"/> 
      <GradientStop Color="#FFFFFFFF" Offset="1"/> 
     </LinearGradientBrush> 
    </Border.Background> 
</Border> 

<TextBlock x:Name="eventName" Grid.Column="1" Text="Amazing Music" FontSize="24" Margin="5,5,10,5" HorizontalAlignment="Left" VerticalAlignment="Top" Padding="0,0,0,0"/> 
<TextBlock x:Name="eventDescription" Grid.Column="1" Grid.Row="1" Text="Amazin music in that house" TextWrapping="Wrap" FontSize="14" Margin="5" HorizontalAlignment="Left" VerticalAlignment="Top" MaxWidth="300" /> 
</Grid> 

回答

1

我認爲布勞略的東西上。我能夠通過將文本包裝到邊框中的堆疊面板中來正確地包裝和調整大小。將這個XAML放到一個沒有寬度和高度設置的全新用戶控件上。

<Border CornerRadius="20,20,20,20" BorderBrush="#FF000000" BorderThickness="1,1,1,1" 
    Height="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="192" 
    Padding="5"> 
    <Border.Background> 
     <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> 
      <GradientStop Color="#FF2100FF"/> 
      <GradientStop Color="#FFFFFFFF" Offset="1"/> 
     </LinearGradientBrush> 
    </Border.Background> 
    <StackPanel> 
     <TextBlock x:Name="eventName" Text="Amazing Music" FontSize="24" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Padding="0,0,0,0"/> 
     <TextBlock x:Name="eventDescription" Text="Amazin music in that house" TextWrapping="Wrap" FontSize="14" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" MaxWidth="300" /> 
    </StackPanel> 
</Border>