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

NotSupportedException when typing a filter

Mar 31, 2016 at 10:34 AM
Hi!

I set IsAutoFilterEnabled to true in my DataGrid and it looks alright. But as soon as I start typing in one of the filter boxes, I get this exception:


---------------------------

---------------------------
Error in MostraFormModelleria: System.NotSupportedException: Specified method is not supported.

   at System.Windows.Data.CollectionView.set_Filter(Predicate`1 value)

   at System.Windows.Controls.ItemCollection.set_Filter(Predicate`1 value)

   at DataGridExtensions.DataGridFilterHost.EvaluateFilter()

   at DataGridExtensions.DataGridFilterHost.<OnFilterChanged>b__19_0(Object _, EventArgs __)

   at System.Windows.Threading.DispatcherTimer.FireTick(Object unused)

   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)

   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

   at System.Windows.Threading.DispatcherOperation.InvokeImpl()

   at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)

   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)

   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)

   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)

   at MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state)

   at System.Windows.Threading.DispatcherOperation.Invoke()

   at System.Windows.Threading.Dispatcher.ProcessQueue()

   at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)

   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)

   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)

   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)

   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)

   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)

   at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)

   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)

   at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)

   at System.Windows.Window.ShowHelper(Object booleanBox)

   at System.Windows.Window.Show()

   at System.Windows.Window.ShowDialog()

   at FasUtil.ModelleriaForm.MostraFormModelleria(Int32 fk_avazanzamentoModelleria, Object user, DataSource ds, DataSource dsLog) in 
---------------------------
OK   
---------------------------
Any ideas why this is happening? The grid is bound to a DataView
Mar 31, 2016 at 1:15 PM
I think binding to a DataView will generate a BindingListCollectionView, which does not support filtering: https://msdn.microsoft.com/en-us/library/system.windows.data.bindinglistcollectionview.canfilter.aspx
Marked as answer by tomenglert on 10/5/2016 at 6:58 AM
Apr 1, 2016 at 4:28 PM
That was it! Thanks
Sep 6, 2016 at 4:40 PM
I'm seeing the same error.

I fill my datagrid the following way:

MyDataGrid.ItemsSource = New MyDataSetTableAdapters.MyTableAdapter().MyQuery

Is that not compatible with the filtering?
Sep 7, 2016 at 6:45 AM
Source must be a collection. Try ...MyQuery.ToArray()
Oct 31, 2016 at 4:02 PM
How should I convert my DataTable in order to make it filterable? What data type should I cast/convert it to?
Nov 18, 2016 at 6:55 PM
The type you are binding to must implement IList