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
135
xamDataGrid crashing when trying to edit non-string values
posted

I have a simple app with a docking panel and a pane with a data grid in it.

I can bind the data grid to a data source and the data appears OK. The fields are generated automatically.

If I click on a data cell I can edit it, only if the underlying field is a string. If i have a data source with int, float, or datetime columns, then as soon as I click on a data cell to edit it, the app crashes with the following message:

Error HRESULT E_FAIL has been returned from a call to a COM component.

System.Runtime.InteropServices.COMException was unhandled
  Message="Error HRESULT E_FAIL has been returned from a call to a COM component."
  Source="WindowsBase"
  ErrorCode=-2147467259
  StackTrace:
       at MS.Win32.UnsafeNativeMethods.ITfSource.AdviseSink(Guid& riid, Object obj, Int32& cookie)
       at System.Windows.Input.TextServicesCompartment.AdviseNotifySink(ITfCompartmentEventSink sink)
       at System.Windows.Input.InputMethod.InitializeCompartmentEventSink()
       at System.Windows.Input.InputMethod.add_StateChanged(InputMethodStateChangedEventHandler value)
       at Infragistics.Windows.Editors.EditInfo.HookUnhookInputMethodHelper(Boolean hook)
       at Infragistics.Windows.Editors.XamMaskedEditor.ProcessIsBeingEditedAndFocusedChanged(Boolean focused)
       at Infragistics.Windows.Editors.XamMaskedEditor.OnIsKeyboardFocusWithinChanged(DependencyPropertyChangedEventArgs e)
       at System.Windows.UIElement.RaiseIsKeyboardFocusWithinChanged(DependencyPropertyChangedEventArgs args)
       at System.Windows.FocusWithinProperty.FireNotifications(UIElement uie, ContentElement ce, UIElement3D uie3D, Boolean oldValue)
       at System.Windows.ReverseInheritProperty.FirePropertyChangeInAncestry(DependencyObject element, Boolean oldValue, DeferredElementTreeState treeState)
       at System.Windows.ReverseInheritProperty.FirePropertyChangeInAncestry(DependencyObject element, Boolean oldValue, DeferredElementTreeState treeState)
       at System.Windows.ReverseInheritProperty.FirePropertyChangeInAncestry(DependencyObject element, Boolean oldValue, DeferredElementTreeState treeState)
       at System.Windows.ReverseInheritProperty.FirePropertyChangeInAncestry(DependencyObject element, Boolean oldValue, DeferredElementTreeState treeState)
       at System.Windows.ReverseInheritProperty.OnOriginValueChanged(DependencyObject oldOrigin, DependencyObject newOrigin, DeferredElementTreeState& oldTreeState)
       at System.Windows.Input.KeyboardDevice.ChangeFocus(DependencyObject focus, Int32 timestamp)
       at System.Windows.Input.KeyboardDevice.TryChangeFocus(DependencyObject newFocus, IKeyboardInputProvider keyboardInputProvider, Boolean askOld, Boolean askNew, Boolean forceToNullIfFailed)
       at System.Windows.Input.KeyboardDevice.Focus(DependencyObject focus, Boolean askOld, Boolean askNew)
       at System.Windows.Input.KeyboardDevice.Focus(IInputElement element)
       at System.Windows.UIElement.Focus()
       at System.Windows.Input.KeyboardNavigation.Navigate(DependencyObject currentElement, TraversalRequest request, ModifierKeys modifierKeys, DependencyObject firstElement)
       at System.Windows.FrameworkElement.MoveFocus(TraversalRequest request)
       at Infragistics.Windows.Editors.ValueEditor.SetFocusToFocusSite()
       at Infragistics.Windows.Editors.ValueEditor.StartEditMode(Boolean takeFocus)
       at Infragistics.Windows.Editors.ValuePresenter.StartEditMode()
       at Infragistics.Windows.DataPresenter.CellValuePresenter.ActivateAndEnterEditMode()
       at Infragistics.Windows.DataPresenter.CellValuePresenter.ProcessPreviewMouseLeftButtonDown(MouseButtonEventArgs e)
       at Infragistics.Windows.Editors.ValuePresenter.OnPreviewMouseLeftButtonDown(MouseButtonEventArgs e)
       at System.Windows.UIElement.OnPreviewMouseLeftButtonDownThunk(Object sender, MouseButtonEventArgs e)
       at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
       at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
       at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
       at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
       at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
       at System.Windows.UIElement.CrackMouseButtonEventAndReRaiseEvent(DependencyObject sender, MouseButtonEventArgs e)
       at System.Windows.UIElement.OnPreviewMouseDownThunk(Object sender, MouseButtonEventArgs e)
       at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
       at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
       at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
       at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
       at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
       at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
       at System.Windows.Input.InputManager.ProcessStagingArea()
       at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
       at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
       at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
       at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       at System.Windows.Interop.HwndSource.InputFilterMessage(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.WrappedInvoke(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.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.Threading.Dispatcher.Run()
       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()
       ...
  InnerException:

i have been able to reproduce it simply with the following code:

 

    public class DataItem
    {
        private int _val;

        public int Val
        {
            get { return _val; }
            set { _val = value; }
        }
    }

    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();

            this.VehicleDG.DataItems.Add(new DataItem() { Val = 1 });
            this.VehicleDG.DataItems.Add(new DataItem() { Val = 2 });

        }
}

 

<Window x:Class="TestApp.Window1"

  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:igWindows="http://infragistics.com/Windows"
  xmlns:igDock="http://infragistics.com/DockManager"
  xmlns:igDP="http://infragistics.com/DataPresenter"
  xmlns:s="clr-namespace:System;assembly=mscorlib"
  Width="Auto"
  Height="Auto"
  Background="#00FFFFFF"
        Loaded="Window_Loaded"
  >
        <Grid Margin="0,0,0,0">
                <igDock:XamDockManager Theme="Aero">
                    <igDock:XamDockManager.Panes>
                        <igDock:SplitPane igDock:XamDockManager.InitialLocation="DockedLeft">
                            <igDock:ContentPane x:Name="leftEdgeDock" Header="Vehicles">
                        <igDP:XamDataGrid Name="VehicleDG">
                            <igDP:XamDataGrid.FieldLayoutSettings>
                                <igDP:FieldLayoutSettings AutoGenerateFields="True" />
                            </igDP:XamDataGrid.FieldLayoutSettings>
                        </igDP:XamDataGrid>
                    </igDock:ContentPane>
                        </igDock:SplitPane>
                    </igDock:XamDockManager.Panes>
                </igDock:XamDockManager>
        </Grid>
</Window>

If I change the definition of Val in my DataItem class to be a string rather than an int, it works fine.

Any ideas what I am doing wrong?

I am currently evaluating Net Advantage v9,2 and so am using a trial licence, I still have 18 usage days or 9 calendar weeks left. I don't know if this makes any difference. I'm using Vista, Visual Studio 2008 and .NET 3.5