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
440
XamGrid Ellipsis (...) when cell content overflows.
posted

Is there any way that you can set a cell's content to display "..." if the text is larger than the cell containing it?

Example: 

Text is "Something123"

instead of showing:

|Somethin|

Show:

|Someth...|

Parents
  • 17475
    Offline posted

    Hello Palen,

    Thank you for posting.

    The content of the cell is set in a TextBlock. You can set a style for the TextBlock and set its TextTrimming property’s value to CharacterEllipsis so that the text is displayed as “Someth…”.

    <Style x:Key="NewTextBlock" TargetType="TextBlock">

                <Setter Property="TextTrimming" Value="CharacterEllipsis"/>

            </Style>

    This style should be applied as TextBlockStyle of the TextColumn where you want the text to be displayed with ellipsis.

    <ig:XamGrid.Columns>

                    <ig:TextColumn Key="Description" TextBlockStyle="{StaticResource NewTextBlock}">

                    </ig:TextColumn>

                </ig:XamGrid.Columns>

     

    Another approach for achieving this is handling CellControlAttached event of the XamGrid, searching the visual tree for a TextBlock and set its TextTrimming property to CharacterEllipsis.

    private void xamGrid1_CellControlAttached(object sender, Infragistics.Controls.Grids.CellControlAttachedEventArgs e)

            {

     

                TextBlock text = Utilities.GetDescendantFromType(e.Cell.Control, typeof(TextBlock), false) as TextBlock;

                if (text != null)

                {

                    text.TextTrimming = TextTrimming.CharacterEllipsis;

                }

            }

    Please let me know if you have any other questions on the matter.

     

Reply Children
No Data