Joe*_*Joe 5 c# wpf collectionviewsource
我在LifeShaping过滤的PresentationFramework中得到一个空引用:
堆栈跟踪没有给我很多线索:
at System.Windows.Data.ListCollectionView.RestoreLiveShaping()
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.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.Window.ShowHelper(Object booleanBox)
at System.Windows.Window.ShowDialog()
at MVVMSeaCores.AppWindowManager.ShowDialog(Object rootModel, Object context, IDictionary`2 settings)
Run Code Online (Sandbox Code Playgroud)
最后一行是对话框调用,显示保存绑定的复选框的UX ShowOnGraph.
我正在设置像这样的实时整形,基于布尔属性"ShowOnGraph":
KPIBarsView = new CollectionViewSource { Source = KPIBars }.View;
KPIBarsView.Filter = FilterBars;
//grouping
if (KPIBarsView != null && KPIBarsView.CanGroup == true)
{
KPIBarsView.GroupDescriptions.Clear();
KPIBarsView.GroupDescriptions.Add(new PropertyGroupDescription("KPIViewModel.ContextViewModel"));
}
//Live Filtering
ICollectionViewLiveShaping KPIBarsViewLiveShaping = KPIBarsView as ICollectionViewLiveShaping;
if (KPIBarsViewLiveShaping.CanChangeLiveFiltering)
{
KPIBarsViewLiveShaping.LiveFilteringProperties.Add("ShowOnGraph");
KPIBarsViewLiveShaping.IsLiveFiltering = true;
}
Run Code Online (Sandbox Code Playgroud)
如果ShowOnGraph设置为false ,则会按照我的预期过滤项目.但是,只要我尝试不过滤任何东西,ShowOnGraph=true我就会得到这个例外.
这不是"什么是空引用异常"的副本.我知道什么是空引用异常.但在这种情况下,null引用位于Presentation Framework中的System.Windows.Data中.我不知道什么是null,为什么(列表不包含任何空条目,过滤器属性是bool,不能为null).
null对象不在我的代码中,并且我无法进行调试.我进入调试器的所有内容都是发生这种情况时的调度.在一种情况下,它在包含我将其设置为true的列表的对话框中:
没有什么是空的.
我只需要一个按钮来设置ShowOnGraph = false,然后查看异常发生的位置.
编辑:是的,它发生在"无处".只需打开一个空白的"中断模式"页面,没有内容或指示错误发生的位置.
| 归档时间: |
|
| 查看次数: |
1424 次 |
| 最近记录: |