开发者

Adding filter textbox to header of a Listview in Gridview mode

开发者 https://www.devze.com 2023-02-22 21:31 出处:网络
I watched a demo video of Mole 2010 (a WPF debugger) in which there is a nice datagrid feature where the header contains a filter textbox, so you can type in a string and filter for that column. Here

I watched a demo video of Mole 2010 (a WPF debugger) in which there is a nice datagrid feature where the header contains a filter textbox, so you can type in a string and filter for that column. Here is the video, the feature is demonstrated at 3:00 minutes

http://www.youtube.com/watch?v=bgMg61iM9G8&feature=player_embedded#at=180

I am interested in replicating that feature, but I am not sure how to do it gracefully. My application is a WPF MVVM EF app, it's my first WPF app.

  • Is it possible to create a template for the header where I can also add a textbox, and a button with a cross so the contents can be cleared?
  • If so, how could I bind the textbox to filter its column?
  • Should I be hiding the actual header row and making an artificial one where I add my own header and textbox and button etc. and then bind them to filter clause properties that I add to my CollectionViewSource when a filter string is typed? I hoped to avoid this so I could retain sorting by clicking the header.

I dont really kn开发者_运维知识库ow how to start this. Are there any gurus that could suggest how this could be done? Thanks!


You might have a look at the BookLibrary sample application of the WPF Application Framework (WAF). It shows how to use a TextBox for filtering the data in a DataGrid. It uses MVVM and the Entity Framework as well.


you might want to try that : http://dotnetexplorer.blog.com/2011/04/07/wpf-itemscontrol-generic-staticreal-time-filter-custom-control-presentation/ => it filters any collections and you just have to decalre the control in XAML...

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号