Question Searchable DataGrid

  • mardi 19 avril 2011 22:37
     
     

    I want to implement a searchable datagrid and highlight the searched text without any additional control for typing text (like Textbox ...)
    this an image that represent the idea you just type the text and it highlight the target.

    http://img696.imageshack.us/f/datagrid.png/

     

Toutes les réponses

  • mardi 5 juin 2012 13:37
     
     

    Hello,

    for the filter, you could use a CollectionView
    http://msdn.microsoft.com/fr-fr/library/system.windows.data.collectionview.aspx

    You have to set the SourceCollection property with your original collection, then you just have to set the Filter property with a delegate determining whether each item must be included in the "View" of the original list.

    highlighting text in the datagrid seems to me tricky wihtout specific developpment. You won't avoid an agreed binding (ancestorType, or binding a property that is supposed to be found in the datacontext and so on) in the style of the row. A DataTriger could handle the value and setting the background color of the root grid of the row.
    According to me, inheriting from DataGrid would be suitable in this case to add SearchedValue property, HighlitedRowBackground...

    Hope this will help a bit