This is a migrated thread and some comments may be shown as answers.

Text Wrap and Search as you type

2 Answers 113 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Bob asked on 24 Feb 2012, 03:41 PM

Hello,

We are using the search as you type feature described in your blog:

http://blogs.telerik.com/stefandobrev/posts/10-01-18/highlighting-inline-search-for-radgridview-for-silverlight.aspx 

However, we noticed that once the HighlightingTextBlock was applied to the cell, the TextWrapping attribute was lost.  Can you please provide an example of the correct way to support TextWrapping with the search feature?  Thanks for any help.

2 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 29 Feb 2012, 01:43 PM
Hi  Bob,

The technique illustrated in the blogpost uses the the highlighting textblock of Jeff Wilcox . I believe the right way would be to modify the code from his blog in order to enable text wrapping.

All the best,
Pavel Pavlov
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
answered on 29 Feb 2012, 09:06 PM
Hi Pavel,

I got this to work by looking at the parent cell and column when the template was applied in the HighlightingTextBlock.  Hopefully, this is the right way to solve this issue.

/// <summary>
/// Override the apply template handler.
/// </summary>
public override void OnApplyTemplate()
{
    base.OnApplyTemplate();
 
    // Grab the template part
    TextBlock = GetTemplateChild(TextBlockName) as TextBlock;
 
    if (TextBlock != null)
    {
        if ((this.Parent != null) && (this.Parent.GetType() == typeof(Telerik.Windows.Controls.GridView.GridViewCell)))
            TextBlock.TextWrapping = ((Telerik.Windows.Controls.GridView.GridViewCell)(this.Parent)).Column.TextWrapping;
 
        if (LinkStyle)
            TextBlock.TextDecorations = TextDecorations.Underline;
 
        // Re-apply the text value
        string text = Text;
        Text = null;
        Text = text;
    }
}
Tags
GridView
Asked by
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Answers by
Pavel Pavlov
Telerik team
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Share this question
or