Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1655
Adding "..." in the cell value if length is more than cell width.
posted

Hi,

I have a cell value in the XamDataGrid. lets say "XamDataGrid is too good". The length of this string is 23.

Now if the width of the cell is 10 then it should show 7 charecters of the cell value and appended with these 3 characters  "...".

then it should show like "XamData..." in the cell.

Can anyone please help me out.

Thanks

Ritesh

 

Parents
  • 9836
    Suggested Answer
    posted

    Hi Ritesh,

    In order to achieve such functionality you would need to retemplate the default style for the XamTextEditor and set the TextTrimming property of the TextBlock element in the control template.

    <TextBlock x:Name="TextBlock"
                                Margin="{TemplateBinding Padding}"
                                Text="{TemplateBinding DisplayText}"
                                TextWrapping="{TemplateBinding TextWrapping}"
                                TextTrimming="CharacterEllipsis"
                                HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                TextAlignment="{TemplateBinding TextAlignmentResolved}"/>

    If you need the trimming to appear when the width is less then particullar value (10 in your case) you can try to set this property to "none" or to "CharacterEllipsis" based on the TextBlock.Width using e.g. DataTrigger.

    I hope this helps.

    Vlad

     

Reply Children