WPF DataGrid EnableColumnVirtualization="True" 在 DataGridCellsPanel.get_HasCorrectRealizedColumns() 处引发 NullReferenceException

2024-01-18

我有一个 WPF DataGridEnableColumnVirtualization="True"。用户控件会显示,但一旦您滚动或调整大小,您就会收到一个NullReferenceException at DataGridCellsPanel.get_HasCorrectRealizedColumns()。环境ColumnVirtualization="False"更正了该问题。我尝试过删除EnableRowVirtualization="True"...等等认为这可能是由于属性的组合造成的,但我可以用一个非常简单的 DataGrid 重现该问题:

<DataGrid ItemsSource="{Binding Items}" AutoGenerateColumns="True" EnableColumnVirtualization="True"

还有其他人遇到过这个吗?我运行的是Win7 64。谢谢大家!

   at System.Windows.Controls.DataGridCellsPanel.get_HasCorrectRealizedColumns()
   at System.Windows.Controls.Primitives.DataGridCellsPresenter.SyncProperties(Boolean forcePrepareCells)
   at System.Windows.Controls.DataGridRow.SyncProperties(Boolean forcePrepareCells)
   at System.Windows.Controls.DataGridRow.PrepareRow(Object item, DataGrid owningDataGrid)
   at System.Windows.Controls.DataGrid.PrepareContainerForItemOverride(DependencyObject element, Object item)
   at System.Windows.Controls.ItemsControl.MS.Internal.Controls.IGeneratorHost.PrepareItemContainer(DependencyObject container, Object item)
   at System.Windows.Controls.VirtualizingStackPanel.InsertContainer(Int32 childIndex, UIElement container, Boolean isRecycled)
   at System.Windows.Controls.VirtualizingStackPanel.AddContainerFromGenerator(Int32 childIndex, UIElement child, Boolean newlyRealized, Boolean isBeforeViewport)
   at System.Windows.Controls.VirtualizingStackPanel.MeasureChild(IItemContainerGenerator& generator, IContainItemStorage& itemStorageProvider, IContainItemStorage& parentItemStorageProvider, Object& parentItem, Boolean& hasUniformOrAverageContainerSizeBeenSet, Double& computedUniformOrAverageContainerSize, Boolean& computedAreContainersUniformlySized, IList& items, Object& item, IList& children, Int32& childIndex, Boolean& visualOrderChanged, Boolean& isHorizontal, Size& childConstraint, Rect& viewport, VirtualizationCacheLength& cacheSize, VirtualizationCacheLengthUnit& cacheUnit, Boolean& foundFirstItemInViewport, Double& firstItemInViewportOffset, Size& stackPixelSize, Size& stackPixelSizeInViewport, Size& stackPixelSizeInCacheBeforeViewport, Size& stackPixelSizeInCacheAfterViewport, Size& stackLogicalSize, Size& stackLogicalSizeInViewport, Size& stackLogicalSizeInCacheBeforeViewport, Size& stackLogicalSizeInCacheAfterViewport, Boolean& mustDisableVirtualization, Boolean isBeforeFirstItem, Boolean isAfterFirstItem, Boolean isAfterLastItem, Boolean skipActualMeasure, Boolean skipGeneration, Boolean& hasBringIntoViewContainerBeenMeasured, Boolean& hasVirtualizingChildren)
   at System.Windows.Controls.VirtualizingStackPanel.MeasureOverrideImpl(Size constraint, Nullable`1& lastPageSafeOffset, List`1& previouslyMeasuredOffsets, Boolean remeasure)
   at System.Windows.Controls.VirtualizingStackPanel.MeasureOverride(Size constraint)
   at System.Windows.Controls.Primitives.DataGridRowsPresenter.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.ContextLayoutManager.UpdateLayout()
   at System.Windows.Controls.VirtualizingStackPanel.<>c__DisplayClassa.<InitializeViewport>b__7()
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, 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 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 MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, 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.Application.RunInternal(Window window)
   at System.Windows.Application.Run()
   at ....App.Main() in c:\....\obj\Debug\App.g.cs:line 0

我能够通过改变来实现它VirtualizationMode从回收到标准。

    <DataGrid ItemsSource="{Binding Items}" 
     AutoGenerateColumns="True"
     EnableColumnVirtualization="True"
     Standard.VirtualizingStackPanel.IsVirtualizing="True"
     VirtualizingStackPanel.VirtualizationMode="Standard">

我仍然想知道为什么回收不起作用......错误?

希望这可以帮助任何遇到同样问题的人。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

WPF DataGrid EnableColumnVirtualization="True" 在 DataGridCellsPanel.get_HasCorrectRealizedColumns() 处引发 NullReferenceException 的相关文章

随机推荐

  • 如何平滑matplotlib等高线图?

    I have numpy array with this shape 33 10 When I plot contour I get ugly image like this while contour 似乎没有任何关于平滑或某种插值功能的
  • 在 DataFrame 中按多列条件删除行

    我有一个 pandas 数据框 我试图根据所选列的条件删除行 如果这些选择列中的值为零 则应删除这些行 这是一个例子 import pandas as pd t pd DataFrame a 1 0 0 2 b 1 2 0 0 c 1 2
  • 反编译 Adob​​e AIR 应用程序

    是否有反编译 Adob e AIR 应用程序的工具 我想检查它们在我制作的应用程序上如何工作 打包的 AIR 文件 带有 air 扩展名的文件 是 ZIP 文件 您可以使用任何 ZIP 程序将它们分开 但是 AIR 应用程序可以用 Flas
  • 将sql结果转换为列表python

    我是 python 初学者 我想将 sql 结果转换为列表 这是我的代码 cursor connnect db query SELECT FROM tbl cursor execute query options list for i ro
  • WebGl 将 float 打包到 v4 中

    我有来自 Threejs 示例的代码示例 http twojs org examples webgl animation cloth http threejs org examples webgl animation cloth 5D其中浮
  • Matlab:如何将元胞数组转换为字符串数组?

    我有一个大小为 14676x117 的元胞数组调用myCellArray 我想提取存储在中的值myCellArray 2 14676 1 在字符串数组中 运行下面的脚本仅返回单个字符串值 而不返回字符串数组 gt gt y myCellAr
  • 我应该使用什么 SQL Server 数据类型来存储字节[]

    我想在我的 SQL Server 中存储一个字节数组 您建议使用什么数据类型或预插入操作来存储这些数据 我没想到这些byte 长度超过 1024 varbinary 1024 这就是您正在寻找的 SQL Server 中的二进制值存储有以下
  • Azure Web 应用程序容器和 docker 命令

    我将 Azure 资源 容器的 Web 应用程序 与 Linux docker 映像一起使用 我想使用 docker 命令 例如 dockerspect 但我不确定这是如何实现的 通过 Kudo 界面 这似乎不可能 我什至无法获取当前部署的
  • 禁用选项卡栏项目 - Swift

    如何禁用特定选项卡栏项目 就像第三个图标一样 self tabBarItem items 2 enabled false 一定有一种方法可以完成像单行这样简单的任务吗 上面的不行 这是答案 if let arrayOfTabBarItems
  • C# 从 JSON 响应创建 Deedle DataFrame

    我在将此请求的 JSON 响应加载到 Deedle DataFrame 中时遇到了一些问题 在 JSON 中 我感兴趣的是它的特性 更具体地说 对于每个功能都有属性 我本质上只想将这些属性的集合加载到 DataFrame 中 在这种特殊情况
  • â�� 在我的 purify 后的 html 中

    我有一个数据库 我正在重建表结构 这很糟糕 所以我将一些数据从一个表移植到另一个表 这些数据似乎是从 MSO 产品复制粘贴的 因此当我获取数据时 我使用 htmlpurifier 和 php 中的一些 str replace 对其进行清理
  • 在 Eclipse 中运行时从 pom 获取 Maven 项目版本和工件 ID

    当我遇到这个问题时 我正在寻找如何从 Maven pom 或清单获取应用程序名称 artifact id 和版本在运行时获取 Maven 工件版本 https stackoverflow com questions 2712970 how
  • 基于角色的访问控制(RBAC)关心权限还是角色?

    看完之后http en wikipedia org wiki Role based access control http en wikipedia org wiki Role based access control看到人们构建授权 访问
  • 同时提交多个分支

    我想同时在不同的分支上进行一次提交 因为在我的项目中 我针对不同的客户端有不同的分支 假设我已经在分支 A 上进行了新功能提交 我是否也可以同时在分支 B 分支 C 和 D 上进行此提交 有没有这方面的快捷命令 这样签出一个分支 每次都要c
  • 如何使用 cgmath::Matrix 作为 glium 中的统一参数?

    我正在尝试整合cgmath图书馆进入我的第一个实验glium 但我不知道如何通过我的Matrix4反对draw call My uniforms对象的定义如下 let uniforms uniform matrix cgmath Matri
  • ext js中有列点击事件吗?

    我正在使用 Ext grid gridpanel 在 rowclick 事件中 我们可以处理网格的行单击 是否有任何事件可以处理网格的列单击 我想选择网格的特定列 没有什么特别的columnclick网格面板或选择模型上的事件 但您可以收听
  • ng-click 在使用 ng-bind-html 的控制器内不起作用

    在我的代码下面 ng click 不起作用 当我检查检查元素 ng click 未显示时 请帮助我该怎么做 var app angular module myApp ngSanitize app controller myCtrl func
  • 当最大工作进程数大于 1 时,Web 应用程序运行速度是否更快?

    对于IIS7 当最大工作进程数大于 1 时 Web 应用程序运行速度是否更快 通过将最大工作进程数增加到超过 1 您将创建一个网络花园 所以简短的回答是 可能不会 除非 去引用克里斯 亚当斯 http yuppieredneck com 前
  • 如何使非冻结数据类冻结,反之亦然?

    我想知道制作数据类的简单方法bar frozen dataclass class Bar foo int bar Bar foo 1 换句话说 我想要一个如下所示的函数some fn to freeze frozen bar some fn
  • WPF DataGrid EnableColumnVirtualization="True" 在 DataGridCellsPanel.get_HasCorrectRealizedColumns() 处引发 NullReferenceException

    我有一个 WPF DataGridEnableColumnVirtualization True 用户控件会显示 但一旦您滚动或调整大小 您就会收到一个NullReferenceException at DataGridCellsPanel