Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
660
ArgumentNullException was unhandled "Key cannot be null". XamDataGrid binding.
posted

What I have is a project that takes an xml definition and draws screens from code behind only. This is the way that this project has to be done. The project is using Full .NET 4.0 (no client profile), Entity Framework 5.0 and Infragistics WOF LOB 12.1 . Note that ParentData is an instance of the Entities, and WorkArea is a globally used Dictionary(of String, DBSet). I receive the error "ArgumentNullException was unhandled" along with the "Key cannot be null" error when the data is binding if I remove the pointer to set the grid's datasource the issue does not occur. From the names of the methods in the stack below it appears that the grid is trying to autofit itself. As you can see I am setting the row and column for the field to position them in very specific locations and hacking the use of the ColumnSpan to actually position the columns based on the widths of the fields. However, I removed all of this code and still get the same error. Can anyone shed some light on this?

Thank You

Devin

        Dim xdg As New XamDataGrid
        Dim flc As FieldLayoutCollection = xdg.FieldLayouts
        xdg.AutoFit = True
        xdg.FieldLayoutSettings.AutoFitMode = AutoFitMode.Always
        xdg.FieldLayoutSettings.AutoGenerateFields = False
        xdg.FieldLayoutSettings.AutoArrangeCells = AutoArrangeCells.Never
        Dim fl As New FieldLayout
        For Each fe As FormElement In gf.FormElements
            Dim fld As New UnboundField
            Dim xy As XY = Viewer.convertToPoint(fe.position)
            fld.Row = xy._Y
            fld.Column = xy._X
     
            fld.Label = sFld.longLabel
            Dim w As Int16 = 1
            If sFld.width > 0 Then
                w = sFld.width
            ElseIf sFld.precision > 0 Then
                w = sFld.precision + sFld.decimals
            ElseIf sFld.size > 0 Then
                w = sFld.size
            End If
            If w > 0 Then
                fld.ColumnSpan = w
            End If
           
            fl.Fields.Add(fld)
        Next
        flc.Add(fl)

        'Load Data
        Dim chld As DbSet(Of Entities5Library.customer) = ParentData.customers
        WorkArea.Add("clntstebllngschdle", chld)
        WorkArea("clntstebllngschdle").Load()
        xdg.DataSource = From x In WorkArea("customer").Local Where x.customer_id = ParentValue

Here is the stack:

at System.Collections.Specialized.ListDictionary.get_Item(Object key)
at System.Collections.Specialized.HybridDictionary.get_Item(Object key)
at System.ComponentModel.PropertyDescriptorCollection.Find(String name, Boolean ignoreCase)
at Infragistics.Windows.DataPresenter.FieldLayout.LayoutPropertyDescriptorProvider.VerifyFieldDescriptors()
at Infragistics.Windows.DataPresenter.VirtualizingDataRecordCellPanel.VerifyPropertyDescriptorProvider()
at Infragistics.Windows.DataPresenter.VirtualizingDataRecordCellPanel.MeasureOverride(Size availableSize)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at Infragistics.Windows.Controls.CardPanel.MeasureOverride(Size availableSize)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Control.MeasureOverride(Size constraint)
at Infragistics.Windows.DataPresenter.DataRecordCellArea.MeasureOverride(Size availableSize)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.DockPanel.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)
at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at Infragistics.Windows.Controls.CardPanel.MeasureOverride(Size availableSize)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Control.MeasureOverride(Size constraint)
at Infragistics.Windows.DataPresenter.RecordPresenter.MeasureOverride(Size availableSize)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at Infragistics.Windows.DataPresenter.GridViewPanelFlat.GenerationCache.GenerateNextElement(Boolean isHeader)
at Infragistics.Windows.DataPresenter.GridViewPanelFlat.GenerationCache.GenerateScrollableRecords()
at Infragistics.Windows.DataPresenter.GridViewPanelFlat.GenerationCache.GenerateAllRecords()
at Infragistics.Windows.DataPresenter.GridViewPanelFlat.MeasureOverride(Size availableSize)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.ContextLayoutManager.UpdateLayout()
at System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg)
at System.Windows.Media.MediaContext.InvokeOnRenderCallback.DoWork()
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.DispatcherOperation.InvokeImpl()
at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
at System.Threading.ExecutionContext.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
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.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.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
at System.Windows.Application.Run(Window window)
at System.Windows.Application.Run()
at SamproScreenReader.Application.Main() in C:\Users\dnapoleon\documents\visual studio 2010\Projects\SamproScreenReader\SamproScreenReader\obj\x86\Debug\Application.g.vb:line 64
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
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()