This project has moved and is read-only. For the latest updates, please go here.

Excellent work!

Jun 26, 2013 at 4:54 PM
I stumbled upon this while trying to search for ways to present column filters in a DataGrid. This does exactly what I need in a very elegant way.

I have a couple of questions:

a) How can I preserve the style that is applied to my DataGrid? I am using the MUI framework and it has already styled the DataGrid. When I set the attached properties:
dgx:DataGridFilter.ContentFilterFactory="{StaticResource RegexContentFilterFactory}"
dgx:DataGridFilter.IsAutoFilterEnabled="True"
to my DataGrid, I loose my existing column header style. How can I get it back?

b) Is there an event that I can subscribe to when I know the filter is finished? I'd like to present a new row count / summary when it is finished.

Thanks again for this great work!
Jun 27, 2013 at 5:01 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Jun 27, 2013 at 5:13 PM
a) It's a bug, will be fixed soon

b) There is an event "Filtering" that you can use. Since the filtering itself is done in the calling thread, you can simply use BeginInvoke to process your code after filtering is done:
using DataGridExtensions;

namespace DataGridExtensionsSample
{
    using System.Windows.Threading;

    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            grid1.GetFilter().Filtering += Grid1_Filtering;
        }

        void Grid1_Filtering(object sender, DataGridFilteringEventArgs e)
        {
            Dispatcher.BeginInvoke(new Action(Grid1_Filtered));
        }

        void Grid1_Filtered()
        {
            // code to invoke after filtering    
        }
Sep 3, 2014 at 5:00 AM
in response to the filtering event, I want to tell my ViewModel to now show an updated count of visible rows. Normally I would do something like this:
var gridView  = CollectionViewSource.GetDefaultView(Specs);
var v = (ListCollectionView)gridView;
int visible = v.Count;
but this returns all rows when this is called via the filtering event. What should I do in this case?
Sep 6, 2014 at 5:15 PM
Edited Sep 6, 2014 at 5:15 PM
..further, I have tried checking my grid's Items.Count property in the filtering event and I still get the same number of total rows, and not the visible ones..
private void OnFiltering(object s, DataGridFilteringEventArgs e)
{
    DispatcherHelper.CheckBeginInvokeOnUI(() => 
    { 
        logger.Debug("in filtering");
        int count = allMto.Items.Count; // still the same full item count...
    });
}