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
80
Highlight search text in XAMGrid.
posted

I have a XAMGrid and a text box on my form.

Grid datasource is a collection.

If user types some text in the textbox I want to highlight all the matching values in one of the column of the grid.

Like say grid has first name and last name column. If user types sam then I want to highlight only the text "SAM" in the first name column in the grid. So if there are total 30 rows in the grid and there are 5 rows with text containing SAM then I want to highlight only the matching text not the whole cell/row. Also other rows shoould be visible even if they dont have any matching values.

Please advice how can I achieve this using XAMGrid?

Thanks a lot.

Parents
  • 34510
    Verified Answer
    Offline posted

    Hi Bane,

    There is this really nice stackoverflow post about how to do this using our WPF XamDataGrid but you may be able to adapt part of this for the XamGrid, specifically the part where it retemplates the cell to use a special type of TextBlock which is responsible for the highlighting the text.  Check it out here:
    http://stackoverflow.com/questions/7854570/how-to-implement-a-search-that-causes-multi-column-record-filtering-in-xamdatagr

    The basic gist is that you would create an attached property called FilterText and then you would retemplate the cells to use the special highlighting textblock.  This textblock would bind up to the XamDataGrid where the FilterText attached property would be attached so that it has access to the filter text.  Then it would check if it's own text contains the filter text and if so it highlights the text.  I believe the post also applies a filter which filters out the rows that don't match so you might want to skip that part of the post if you don't actually want to filter out rows.

    Let me know if you have any questions.

Reply Children
No Data