2011-07-11 3 views
2

私は製品のイメージの下に商品説明を表示するためにテキストブロックを使用しています。テキストは100pxの幅で固定する必要がありますが、高さは30pxまで拡大できます。テキストがまだ収まらない場合は、省略記号を表示する必要があります。ここに私のxamlです:WPF textblockは、複数の行をWindows 7で切り捨てます。

<StackPanel> 
    <!-- I use canvas here to reserve some space for animation (grow/shrink) --> 
    <Canvas Height="75" Width="75"> 
    <Image x:Name="picture" Height="64" Width="64" .../> 
    <Canvas/> 
    <TextBlock Width="100" MaxHeight="30" 
     TextTrimming="CharacterEllipsis" TextWrapping="Wrap" 
     Text="{Binding Path=ProductDescription}" 
     HorizontalAlignment="Center" VerticalAlignment="Top" TextAlignment="Center"> 
</StackPanel> 

説明は複数の行を持つことができます。たとえば、「Wireless Mouse \ nQuantity:20」と入力します。 XPでは大丈夫ですが、Windows 7では最初の行だけが表示され、省略記号はありません。誰でも私のxamlで問題を見つけることができますか?

答えて

2

例にはいくつかのエラーがあります。 "... />"は有効なXAMLではなく、TextBlockに終了タグがありません。

は以下のXAMLは、Windows 7上で私のためにうまく働いた:

<StackPanel> 
    <!-- I use canvas here to reserve some space for animation (grow/shrink) --> 
    <Canvas Height="75" Width="75">  
     <Image x:Name="picture" Height="64" Width="64" /> 
    </Canvas> 

    <TextBlock Width="100" MaxHeight="30"   
     TextTrimming="CharacterEllipsis" TextWrapping="Wrap"   
     Text="I use canvas here to reserve some space for animation (grow/shrink)"   
     HorizontalAlignment="Center" 
     VerticalAlignment="Top" 
     TextAlignment="Center" />  
</StackPanel> 
0

フォントサイズに応じて、MaxHeightはほぼ1行のテキストであるため、テキストブロックの高さは増加できません。それを変更するか、完全に削除してください。

関連する問題