Home Forums WPF controls Xceed DataGrid for WPF Error with EntitySet

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #23156 |

    I have a DataGridControl bound to an EntitySet like this:

    <Window.Resources>
    <ObjectDataProvider x:Key=”mforder” />
    </Window.Resources>
    …<more XAML here>…
    <xcdg:DataGridControl x:Name=”notesdatagrid” Grid.Row=”1″ Grid.Column=”1″
    CellEditorDisplayConditions=”MouseOverCell”
    EditTriggers=”BeginEditCommand,ActivationGesture”
    ItemScrollingBehavior=”Immediate”
    DataContext=”{Binding Source={StaticResource mforder}}”
    ItemsSource=”{Binding Path=MFNote}” >

    When I navigate between records, I will periodically get an error. The navigation process involves replacing the ObjectInstance property of mforder with a new order object.

    The error looks likea DLinq error, but am not 100% sure. Since DLinq is in CTP and DataGrid is still young I’m posting both places. Here’s the error:

    System.ArgumentException was unhandled
    Message=”index”
    Source=”System.Data.DLinq”
    StackTrace:
    at System.Data.DLinq.EntitySet`1.get_Item(Int32 index)
    at System.Data.DLinq.EntitySet`1.System.Collections.IList.get_Item(Int32 index)
    at System.Windows.Data.BindingListCollectionView.GetItemAt(Int32 index)
    at System.Windows.Controls.ItemCollection.GetItemAt(Int32 index)
    at System.Windows.Controls.ItemCollection.get_Item(Int32 index)
    at Xceed.Wpf.DataGrid.CustomItemContainerGenerator.System.Windows.Controls.Primitives.IItemContainerGenerator.GenerateNext(Boolean& isNewlyRealized)
    at Xceed.Wpf.DataGrid.VirtualizingStackPanel.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.ItemsPresenter.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.Controls.ScrollContentPresenter.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 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 System.Windows.Controls.ScrollViewer.MeasureOverride(Size constraint)
    at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
    at System.Windows.UIElement.Measure(Size availableSize)
    at System.Windows.Controls.Decorator.MeasureOverride(Size constraint)
    at System.Windows.Documents.AdornerDecorator.MeasureOverride(Size constraint)
    at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
    at System.Windows.UIElement.Measure(Size availableSize)
    at System.Windows.Controls.Border.MeasureOverride(Size constraint)
    at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
    at System.Windows.UIElement.Measure(Size availableSize)
    at System.Windows.Controls.Control.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.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.AnimatedRenderMessageHandler(Object resizedCompositionTarget)
    at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
    at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, 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)
    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, Boolean isSingleParameter)
    at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
    at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter)
    at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)
    at MS.Win32.HwndSubclass.Subc

    Imported from legacy forums. Posted by Brian (had 4104 views)

    Xceed Support
    Member
    Post count: 5658

    Hi…

    At first sight, looking at the exception call stack… the exception effectively comes from the data source…

    However, there are few things that I’d like to clarify, looking at your code/description.

    You mention that you are “replacing the ObjectInstance property of mforder with a new order object”. However, I do not see in either the DataContext or the ItemsSource binding a reference to the ObjectInstance property…

    Second, I’d like to know if it is intentionally that you are binding the DataContext to a StaticResource reference… Effectivelly, since StaticResource expressions are evaluated only once (when initially parsed), the Binding would never change value (say, if you changed the object reference in the resource dictionary with the “mforder” key).

    Imported from legacy forums. Posted by Marcus [Xceed] (had 289 views)

    User (Old forums)
    Member
    Post count: 23064

    Marc,

    I’ll try to answer your questions as best I can.

    >You mention that you are “replacing the ObjectInstance property of mforder with a new order object”. However, I do not see in either the DataContext or the ItemsSource binding a reference to the ObjectInstance property…

    ObjectInstance is a property of the ObjectDataProvider. When a DataContext is bound to the ObjectDataProvider, the compiler takes care of linking it to the object stored in ObjectInstance. So when I do this:

    DataContext=”{Binding Source={StaticResource ResourceKey=mforder}}”
    ItemsSource=”{Binding Path=MFNote}”

    I’m essentially binding to the MFNote property of whatever is represented by mforder. I know that mforder represents an MFOrder object, with has a EntitySet property named MFNote.

    > Second, I’d like to know if it is intentionally that you are binding the DataContext to a StaticResource reference
    I have tried binding to a DynamicResource, but receive this error:

    System.Windows.Markup.XamlParseException occurred
    Message=”A ‘DynamicResourceExtension’ cannot be set on the ‘Source’ property of type ‘Binding’. A ‘DynamicResourceExtension’ can only be set on a DependencyProperty of a DependencyObject.”

    Perhaps you can suggest an alternate way to Dynamically bind to an <ObjectDataSource>? That’s what I’ll look for.

    Brian

    Imported from legacy forums. Posted by Brian (had 391 views)

    User (Old forums)
    Member
    Post count: 23064

    >…value (say, if you changed the object reference in the resource dictionary with the “mforder” key).

    BTW, When I update the object reference with the mforder key, the DataGridControl refreshes automatically.

    Imported from legacy forums. Posted by Brian (had 290 views)

    User (Old forums)
    Member
    Post count: 23064

    Do you have the Linq CTP installed? I can try to provide a project if you’d like.

    Imported from legacy forums. Posted by Brian (had 311 views)

    User (Old forums)
    Member
    Post count: 23064

    Just hoping to revive this post because we still have yet to figure out this problem.

    Thanks

    Imported from legacy forums. Posted by dustin (had 5113 views)

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.