将属性绑定到 Xceed Datagrid 中的按钮时出现 NullReferenceException
这让我发疯。仅当数据网格足够大以至于需要滚动条时,该问题才会出现,因此我强烈建议数据虚拟化在这方面发挥作用。从下面的 xaml 中可以看到,为此数据网格定义的最后一列是一个按钮,其可见性绑定到作为控件的数据源的 DataGridCollectionView 上的布尔值“ErrorsPresent”属性。 由于某种原因,我不知道,当将大数据集加载到控件中时,会出现一些空行,每个属性中都有空值。如果我注释掉最后一列,网格及其数据会正确显示,但是当实际处理行的数据时(如在转换器中),我会在PresentationFramework中收到这个令人讨厌的错误。很抱歉将其全部包含在内,但我想演示其所有 Windows 代码:
'APreII.vshost.exe'(托管(v4.0.30319)):已加载'C:\ Windows \ Microsoft.Net \ assembly \ GAC_MSIL \Accessibility\v4.0_4.0.0.0__b03f5f7f11d50a3a\Accessibility.dll' System.Transactions 关键:0:http://msdn.microsoft.com/TraceCodes/System/ActivityTracing/2004/07/Reliability/Exception/UnhandledUnhandled 异常APreII.vshost.exeSystem.NullReferenceException,mscorlib,版本=4.0.0.0,文化=中性,PublicKeyToken=b77a5c561934e089对象引用未设置为对象的实例。在 System.Windows.Data.BindingExpression.TransferValue(对象 newValue,布尔值 isASubPropertyChange) 在 System.Windows.Data.BindingExpression.Activate(对象项) 在 System.Windows.Data.BindingExpression.AttachToContext(AttachAttempt 尝试) 在System.Windows.Data.BindingExpression.MS.Internal.Data.IDataBindEngineClient.AttachToContext(布尔lastChance) 在MS.Internal.Data.DataBindEngine.Task.Run(布尔lastChance) 在 MS.Internal.Data.DataBindEngine.Run(对象 arg) 在 MS.Internal.Data.DataBindEngine.OnLayoutUpdated(对象发送者,EventArgs e) 在 System.Windows.ContextLayoutManager.fireLayoutUpdateEvent() 在 System.Windows.ContextLayoutManager.UpdateLayout() 在 System.Windows.ContextLayoutManager.UpdateLayoutCallback(对象 arg) 在 System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks() 在 System.Windows.Media.MediaContext.RenderMessageHandlerCore(对象调整大小的CompositionTarget) 在 System.Windows.Media.MediaContext.RenderMessageHandler(对象调整大小的CompositionTarget) 在 System.Windows.Threading.ExceptionWrapper.InternalRealCall(委托回调,对象参数,Int32 numArgs) 在 MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(对象源,委托方法,对象参数,Int32 numArgs,委托 catchHandler) 在 System.Windows.Threading.Dispatcher.WrappedInvoke(委托回调,对象参数,Int32 numArgs,委托 catchHandler) 在 System.Windows.Threading.DispatcherOperation.InvokeImpl() 在 System.Threading.ExecutionContext.runTryCode(对象 userData) 在System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode代码,CleanupCode backoutCode,对象userData) 在System.Threading.ExecutionContext.Run(ExecutionContextexecutionContext,ContextCallback回调,对象状态,布尔ignoreSyncCtx) 在 System.Threading.ExecutionContext.Run(ExecutionContextexecutionContext,ContextCallback 回调,对象状态) 在 System.Windows.Threading.DispatcherOperation.Invoke() 在 System.Windows.Threading.Dispatcher.ProcessQueue() 在 System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd、Int32 msg、IntPtr wParam、IntPtr lParam、Boolean& 处理) 在 MS.Win32.HwndWrapper.WndProc(IntPtr hwnd、Int32 msg、IntPtr wParam、IntPtr lParam、Boolean& 处理) 在 MS.Win32.HwndSubclass.DispatcherCallbackOperation(对象 o) 在 System.Windows.Threading.ExceptionWrapper.InternalRealCall(委托回调,对象参数,Int32 numArgs) 在 MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(对象源,委托方法,对象参数,Int32 numArgs,委托 catchHandler) 在 System.Windows.Threading.Dispatcher.WrappedInvoke(委托回调,对象参数,Int32 numArgs,委托 catchHandler) 在 System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority 优先级、TimeSpan 超时、委托方法、对象参数、Int32 numArgs) 在MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd,Int32 msg,IntPtr wParam,IntPtr lParam) 在 MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg) 在System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame框架) 在 System.Windows.Application.RunInternal(窗口窗口) 在 System.Windows.Application.Run() 在 D:\tfs\Hermes\dev\Hermes5.0\src\UIServices\APreII\obj\Debug\App.g.cs 中的 APreII.App.Main() 处:第 0 行 在 System.AppDomain._nExecuteAssembly(RuntimeAssembly 程序集,String[] args) 在 System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContextactivationContext,String[]activationCustomData) 在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone() 在System.Threading.ExecutionContext.Run(ExecutionContextexecutionContext,ContextCallback回调,对象状态,布尔ignoreSyncCtx) 在 System.Threading.ExecutionContext.Run(ExecutionContextexecutionContext,ContextCallback 回调,对象状态) 在 System.Threading.ThreadHelper.ThreadStart()System.NullReferenceException:未将对象引用设置为对象的实例。 在 System.Windows.Data.BindingExpression.TransferValue(对象 newValue,布尔值 isASubPropertyChange) 在 System.Windows.Data.BindingExpression.Activate(对象项) 在 System.Windows.Data.BindingExpression.AttachToContext(AttachAttempt 尝试) 在System.Windows.Data.BindingExpression.MS.Internal.Data.IDataBindEngineClient.AttachToContext(布尔lastChance) 在MS.Internal.Data.DataBindEngine.Task.Run(布尔lastChance) 在 MS.Internal.Data.DataBindEngine.Run(对象 arg) 在 MS.Internal.Data.DataBindEngine.OnLayoutUpdated(对象发送者,EventArgs e) 在 System.Windows.ContextLayoutManager.fireLayoutUpdateEvent() 在 System.Windows.ContextLayoutManager.UpdateLayout() 在 System.Windows.ContextLayoutManager.UpdateLayoutCallback(对象 arg) 在 System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks() 在 System.Windows.Media.MediaContext.RenderMessageHandlerCore(对象调整大小的CompositionTarget) 在 System.Windows.Media.MediaContext.RenderMessageHandler(对象调整大小的CompositionTarget) 在 System.Windows.Threading.ExceptionWrapper.InternalRealCall(委托回调,对象参数,Int32 numArgs) 在 MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(对象源,委托方法,对象参数,Int32 numArgs,委托 catchHandler) 在 System.Windows.Threading.Dispatcher.WrappedInvoke(委托回调、对象参数、Int32 numArgs、委托 catchHandler) 在 System.Windows.Threading.DispatcherOperation.InvokeImpl() 在 System.Threading.ExecutionContext.runTryCode(对象 userData) 在System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode代码,CleanupCode backoutCode,对象userData) 在System.Threading.ExecutionContext.Run(ExecutionContextexecutionContext,ContextCallback回调,对象状态,布尔ignoreSyncCtx) 在 System.Threading.ExecutionContext.Run(ExecutionContextexecutionContext,ContextCallback 回调,对象状态) 在 System.Windows.Threading.DispatcherOperation.Invoke() 在 System.Windows.Threading.Dispatcher.ProcessQueue() 在 System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd、Int32 msg、IntPtr wParam、IntPtr lParam、Boolean& 处理) 在 MS.Win32.HwndWrapper.WndProc(IntPtr hwnd、Int32 msg、IntPtr wParam、IntPtr lParam、Boolean& 处理) 在 MS.Win32.HwndSubclass.DispatcherCallbackOperation(对象 o) 在 System.Windows.Threading.ExceptionWrapper.InternalRealCall(委托回调,对象参数,Int32 numArgs) 在 MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(对象源,委托方法,对象参数,Int32 numArgs,委托 catchHandler) 在 System.Windows.Threading.Dispatcher.WrappedInvoke(委托回调、对象参数、Int32 numArgs、委托 catchHandler) 在 System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority 优先级、TimeSpan 超时、委托方法、对象参数、Int32 numArgs) 在MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd,Int32 msg,IntPtr wParam,IntPtr lParam) 在 MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg) 在System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame框架) 在 System.Windows.Application.RunInternal(窗口窗口) 在 System.Windows.Application.Run() 在 D:\tfs\Hermes\dev\Hermes5.0\src\UIServices\APreII\obj\Debug\App.g.cs 中的 APreII.App.Main() 处:第 0 行 在 System.AppDomain._nExecuteAssembly(RuntimeAssembly 程序集,String[] args) 在 System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContextactivationContext,String[]activationCustomData) 在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone() 在System.Threading.ExecutionContext.Run(ExecutionContextexecutionContext,ContextCallback回调,对象状态,布尔ignoreSyncCtx) 在 System.Threading.ExecutionContext.Run(ExecutionContextexecutionContext,ContextCallback 回调,对象状态) 在 System.Threading.ThreadHelper.ThreadStart()
Xaml。正如您所看到的,我尝试通过设置 CanContentScroll 和 CanContentScroll 来禁用虚拟化。 ItemScrollingBehavior 属性,没有任何效果。 :
<XceedDG:DataGridControl Grid.Column="2" x:Name="EncounterDataGrid" ItemsSource="{Binding Path = EncounterDataGridCollectionView, UpdateSourceTrigger=PropertyChanged}"
Background="{x:Static Views:DataGridControlBackgroundBrushes.ElementalBlue}" CellErrorStyle="{StaticResource cell_error}"
FontSize="12" AutoCreateColumns="False" ItemScrollingBehavior="Immediate" ScrollViewer.CanContentScroll="False"
EditTriggers="None" NavigationBehavior="RowOnly" CellEditorDisplayConditions="None" >
<XceedDG:DataGridControl.View>
<Views:TableView ColumnStretchMode="All" ShowRowSelectorPane="False" ScrollViewer.CanContentScroll="False"
ColumnStretchMinWidth="100"/>
</XceedDG:DataGridControl.View>
<!--Group Header formatting-->
<XceedDG:DataGridControl.Resources>
<DataTemplate DataType="{x:Type XceedDG:Group}">
<TextBlock Foreground="DarkSlateBlue"
Padding="3,3,3,3" VerticalAlignment="Center"
FontSize="14" FontWeight="Black" MaxWidth="850" TextWrapping="Wrap"
Text="{Binding Path=., Converter={StaticResource GroupHeaderTextConverterType}}"/>
</DataTemplate>
</XceedDG:DataGridControl.Resources>
<!--Visible column definitions-->
<XceedDG:DataGridControl.Columns>
<XceedDG:Column MinWidth="50"
FieldName="AccountNumber"
Title="Account #"
IsMainColumn="True"
ShowInColumnChooser="False"
TextWrapping="Wrap"
ReadOnly="True"
Visible="True"/>
<XceedDG:Column MinWidth="50"
FieldName="DOB"
Title="Date of Birth"
IsMainColumn="False"
ShowInColumnChooser="False"
TextWrapping="Wrap"
ReadOnly="True"
Visible="True"/>
<XceedDG:Column MinWidth="4"
FieldName="Processed"
Title="Processed"
IsMainColumn="False"
ShowInColumnChooser="False"
TextWrapping="Wrap"
ReadOnly="True"
Visible="True"/>
<XceedDG:Column MinWidth="25"
FieldName="ErrorsPresent"
Title="Errors"
IsMainColumn="False"
ShowInColumnChooser="False"
TextWrapping="Wrap"
ReadOnly="True"
Visible="True" >
<XceedDG:Column.CellContentTemplate>
<DataTemplate>
<Button Command="{StaticResource ShowErrorDialogCommand}" CommandParameter="{Binding Path=DataContext, RelativeSource={RelativeSource AncestorType={x:Type XceedDG:DataRow}}}" Foreground="Red"
Content="View Errors" FontSize="11"
Visibility="{Binding RelativeSource={RelativeSource AncestorType={x:Type XceedDG:DataRow}}, Converter={StaticResource VisibilityConverterBooleanDataRow}, ConverterParameter=ErrorsPresent}"/>
</DataTemplate>
</XceedDG:Column.CellContentTemplate>
</XceedDG:Column>
</XceedDG:DataGridControl.Columns>
</XceedDG:DataGridControl>
只是为了咯咯笑,我是如何制作 DataGridCollectionView 的:
private void CreateDataGridCollectionView()
{
EncounterDataGridCollectionView = new DataGridCollectionView(Encounters);
EncounterDataGridCollectionView.Filter = new Predicate<object>(IsIncludedPt);
//Group by unit
PropertyGroupDescription groupDescription = new PropertyGroupDescription("UnitID");
EncounterDataGridCollectionView.GroupDescriptions.Add(groupDescription);
}
感谢您的帮助。我只是不知道如何正确关闭数据虚拟化(如果这是问题),如何防止这些空记录(不在底层数据集和 DataGridCollectionView 中)被 CellContentTemplate Visibility 转换器处理。
This one is driving me nuts. The issue only shows up when the datagrid is large enough to require scroll bars, so I strongly suggest that data virtualisation plays a hand in this. As you can see from the xaml below the last column defined for this datagrid is a button whose visibility is bound to the boolean "ErrorsPresent" property on the DataGridCollectionView that is the datasource for the control.
For some reason, unknown to me, when a big dataset is loaded into the control, there are some empty rows, with null values in every property. If I comment out the last column, the grid and its data display properly, but when the row's data is actually processed (as in the converter) I get this nasty error in the PresentationFramework. I'm sorry to include it all, but I want to demonstrate that its all Windows code :
'APreII.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Accessibility\v4.0_4.0.0.0__b03f5f7f11d50a3a\Accessibility.dll'
System.Transactions Critical: 0 : http://msdn.microsoft.com/TraceCodes/System/ActivityTracing/2004/07/Reliability/Exception/UnhandledUnhandled exceptionAPreII.vshost.exeSystem.NullReferenceException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089Object reference not set to an instance of an object. at System.Windows.Data.BindingExpression.TransferValue(Object newValue, Boolean isASubPropertyChange)
at System.Windows.Data.BindingExpression.Activate(Object item)
at System.Windows.Data.BindingExpression.AttachToContext(AttachAttempt attempt)
at System.Windows.Data.BindingExpression.MS.Internal.Data.IDataBindEngineClient.AttachToContext(Boolean lastChance)
at MS.Internal.Data.DataBindEngine.Task.Run(Boolean lastChance)
at MS.Internal.Data.DataBindEngine.Run(Object arg)
at MS.Internal.Data.DataBindEngine.OnLayoutUpdated(Object sender, EventArgs e)
at System.Windows.ContextLayoutManager.fireLayoutUpdateEvent()
at System.Windows.ContextLayoutManager.UpdateLayout()
at System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg)
at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
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.WrappedInvoke(Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at System.Threading.ExecutionContext.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
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.WrappedInvoke(Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.InvokeImpl(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 APreII.App.Main() in D:\tfs\Hermes\dev\Hermes5.0\src\UIServices\APreII\obj\Debug\App.g.cs:line 0
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()System.NullReferenceException: Object reference not set to an instance of an object.
at System.Windows.Data.BindingExpression.TransferValue(Object newValue, Boolean isASubPropertyChange)
at System.Windows.Data.BindingExpression.Activate(Object item)
at System.Windows.Data.BindingExpression.AttachToContext(AttachAttempt attempt)
at System.Windows.Data.BindingExpression.MS.Internal.Data.IDataBindEngineClient.AttachToContext(Boolean lastChance)
at MS.Internal.Data.DataBindEngine.Task.Run(Boolean lastChance)
at MS.Internal.Data.DataBindEngine.Run(Object arg)
at MS.Internal.Data.DataBindEngine.OnLayoutUpdated(Object sender, EventArgs e)
at System.Windows.ContextLayoutManager.fireLayoutUpdateEvent()
at System.Windows.ContextLayoutManager.UpdateLayout()
at System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg)
at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
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.WrappedInvoke(Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at System.Threading.ExecutionContext.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
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.WrappedInvoke(Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.InvokeImpl(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 APreII.App.Main() in D:\tfs\Hermes\dev\Hermes5.0\src\UIServices\APreII\obj\Debug\App.g.cs:line 0
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
The Xaml. As you can see I've TRIED to disable virtualisation by setting the CanContentScroll & ItemScrollingBehavior properties, which has no effect. :
<XceedDG:DataGridControl Grid.Column="2" x:Name="EncounterDataGrid" ItemsSource="{Binding Path = EncounterDataGridCollectionView, UpdateSourceTrigger=PropertyChanged}"
Background="{x:Static Views:DataGridControlBackgroundBrushes.ElementalBlue}" CellErrorStyle="{StaticResource cell_error}"
FontSize="12" AutoCreateColumns="False" ItemScrollingBehavior="Immediate" ScrollViewer.CanContentScroll="False"
EditTriggers="None" NavigationBehavior="RowOnly" CellEditorDisplayConditions="None" >
<XceedDG:DataGridControl.View>
<Views:TableView ColumnStretchMode="All" ShowRowSelectorPane="False" ScrollViewer.CanContentScroll="False"
ColumnStretchMinWidth="100"/>
</XceedDG:DataGridControl.View>
<!--Group Header formatting-->
<XceedDG:DataGridControl.Resources>
<DataTemplate DataType="{x:Type XceedDG:Group}">
<TextBlock Foreground="DarkSlateBlue"
Padding="3,3,3,3" VerticalAlignment="Center"
FontSize="14" FontWeight="Black" MaxWidth="850" TextWrapping="Wrap"
Text="{Binding Path=., Converter={StaticResource GroupHeaderTextConverterType}}"/>
</DataTemplate>
</XceedDG:DataGridControl.Resources>
<!--Visible column definitions-->
<XceedDG:DataGridControl.Columns>
<XceedDG:Column MinWidth="50"
FieldName="AccountNumber"
Title="Account #"
IsMainColumn="True"
ShowInColumnChooser="False"
TextWrapping="Wrap"
ReadOnly="True"
Visible="True"/>
<XceedDG:Column MinWidth="50"
FieldName="DOB"
Title="Date of Birth"
IsMainColumn="False"
ShowInColumnChooser="False"
TextWrapping="Wrap"
ReadOnly="True"
Visible="True"/>
<XceedDG:Column MinWidth="4"
FieldName="Processed"
Title="Processed"
IsMainColumn="False"
ShowInColumnChooser="False"
TextWrapping="Wrap"
ReadOnly="True"
Visible="True"/>
<XceedDG:Column MinWidth="25"
FieldName="ErrorsPresent"
Title="Errors"
IsMainColumn="False"
ShowInColumnChooser="False"
TextWrapping="Wrap"
ReadOnly="True"
Visible="True" >
<XceedDG:Column.CellContentTemplate>
<DataTemplate>
<Button Command="{StaticResource ShowErrorDialogCommand}" CommandParameter="{Binding Path=DataContext, RelativeSource={RelativeSource AncestorType={x:Type XceedDG:DataRow}}}" Foreground="Red"
Content="View Errors" FontSize="11"
Visibility="{Binding RelativeSource={RelativeSource AncestorType={x:Type XceedDG:DataRow}}, Converter={StaticResource VisibilityConverterBooleanDataRow}, ConverterParameter=ErrorsPresent}"/>
</DataTemplate>
</XceedDG:Column.CellContentTemplate>
</XceedDG:Column>
</XceedDG:DataGridControl.Columns>
</XceedDG:DataGridControl>
And just for giggles, how I'm making the DataGridCollectionView :
private void CreateDataGridCollectionView()
{
EncounterDataGridCollectionView = new DataGridCollectionView(Encounters);
EncounterDataGridCollectionView.Filter = new Predicate<object>(IsIncludedPt);
//Group by unit
PropertyGroupDescription groupDescription = new PropertyGroupDescription("UnitID");
EncounterDataGridCollectionView.GroupDescriptions.Add(groupDescription);
}
Thanks for any help. I just don't know how to properly turn off data virtualisation (if that IS the problem), of how to keep these null records (which are not in the underlying dataset and DataGridCollectionView) from getting processed by the CellContentTemplate Visibility converter.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我讨厌一天后回答我自己的问题,但我们到了。叹。
尽管在转换器调用的 XAML 中,我获取了从一些 Xceed 文档中提取的祖先数据行,但仅将我关心的属性(仅“绑定”)发送到转换器似乎可以工作。
我的猜测是,最初的错误是由另一个线程上的虚拟化完成的一些工作引起的,因此缺少指向我的任何代码的堆栈跟踪。
这有效:
I hate answering my own question 1 day later, but here we are. Sigh.
Although in the XAML for my converter call I was getting the ancestor datarow, which I pulled from some Xceed docs, sending only the property I care about (just 'Binding') to the converter seems to work.
My guess is that the original error was resulting from some work being done with virtualisation on another thread, hence the lack of a stacktrace that points to any of my code.
This works :