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
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
Thanks Vlad for your response.
I am using an IList to bind the data to the data grid. I am not able to bind the details to the TextBlock.
If i am setting text property to any text then its working fine. I have tried Text="{Binding Value}". its not working.
Can you please help me out?
Ritesh,
I'm assuming that you are using the default style for the XamTextEditor and make changes to the TextBlock element within the Template. You can try to change the Text to :
Text="{TemplateBinding DisplayText}"
Let me know if this works in your scenario.