scrollable gridview with fixed searched row in dat

2019-08-27 23:23发布

问题:

I'm trying to implement a "find" feature where the user can enter a value in a textbox (outside of the grid) then click a button to find the row that matches the search criteria. if the search item is found in the gridview that searched record has been fixed at top of the gridview and the remaining records are scrollable except the searched record . i need to show this criteria in wpf .please any one suggest me...

Thank you in advance..

回答1:

You will have a data grid on your view (xaml and xaml.cs) where you will bind the ItemsSource to an observable collection on your view model. You will take your input from your text box and put it through your search algorithm. The search algorithm will filter out data in the collection and you can just move the element you want in the collection to the front.



回答2:

It's a hard problem if you want to do it correctly. For freezing rows, see this: http://blogs.msdn.com/b/vinsibal/archive/2008/10/31/wpf-datagrid-frozen-row-sample.aspx