WPF Data grid Text Ellipsis Not working…

Aug 18, 2010 at 8:21 AM

Hello,

I have a column with long user comments. I load it using following code...

<my:DataGridTextColumn Header="Message" 
                       Binding="{Binding UserMessage, Mode=OneWay}"  
                       CanUserSort="True"> 
    <my:DataGridTextColumn.ElementStyle> 
        <Style TargetType="{x:Type TextBlock}" 
               BasedOn="{StaticResource {x:Type TextBlock}}"> 
               <Setter Property="TextWrapping" 
                       Value="NoWrap" /> 
               <Setter Property="TextTrimming" 
                       Value="CharacterEllipsis"/>                                     
               <Setter Property="ToolTip" 
                       Value="{Binding Path=UserMessage, Mode=OneWay}"/> 
        </Style> 
    </my:DataGridTextColumn.ElementStyle> 
</my:DataGridTextColumn> 

But the ellipsis wont work. The column continues to display long text of data.

Also when I set the width of the textblock explicitly to some value then the ellipsis work fine but when I resize my column it wont show any more text in it.

 

Isnt there a starighforward way to do this?

 

Thx

Vinit Sankhe.