The current value of the SelectionUnit property on the parent DataGrid prevents rows from being selected.

Aug 12, 2008 at 7:31 PM
I got the following exception when I ran the sample from Vincent. (http://blogs.msdn.com/vinsibal/archive/2008/08/11/net-3-5-sp1-and-wpf-datagrid-ctp-is-out-now.aspx)
The exception happened when I tried to insert a new row.

System.InvalidOperationException was unhandled
  Message="The current value of the SelectionUnit property on the parent DataGrid prevents rows from being selected."
  Source="WPFToolkit"
  StackTrace:
       at Microsoft.Windows.Controls.DataGridRow.OnIsSelectedChanged(Object sender, DependencyPropertyChangedEventArgs e) in C:\Downloads\DataGridCTPSample\DataGridCTPSample\Toolkit-release\DataGrid\Microsoft\Windows\Controls\DataGridRow.cs:line 522
       at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
       at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
       at Microsoft.Windows.Controls.DataGridRow.OnPropertyChanged(DependencyPropertyChangedEventArgs e) in C:\Downloads\DataGridCTPSample\DataGridCTPSample\Toolkit-release\DataGrid\Microsoft\Windows\Controls\DataGridRow.cs:line 194
       at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
       at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, OperationType operationType)
       at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, OperationType operationType, Boolean isInternal)
       at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
       at System.Windows.Controls.Primitives.Selector.ItemSetIsSelected(Object item, Boolean value)
       at System.Windows.Controls.Primitives.Selector.OnGeneratorStatusChanged(Object sender, EventArgs e)
       at System.Windows.Controls.ItemContainerGenerator.SetStatus(GeneratorStatus value)
       at System.Windows.Controls.ItemContainerGenerator.Generator.System.IDisposable.Dispose()
       at System.Windows.Controls.VirtualizingStackPanel.BringIndexIntoView(Int32 index)
       at Microsoft.Windows.Controls.DataGridRowsPresenter.InternalBringIndexIntoView(Int32 index) in C:\Downloads\DataGridCTPSample\DataGridCTPSample\Toolkit-release\DataGrid\Microsoft\Windows\Controls\DataGridRowsPresenter.cs:line 35
       at Microsoft.Windows.Controls.DataGrid.ScrollRowIntoView(Object item) in C:\Downloads\DataGridCTPSample\DataGridCTPSample\Toolkit-release\DataGrid\Microsoft\Windows\Controls\DataGrid.cs:line 1226
       at Microsoft.Windows.Controls.DataGrid.ScrollCellIntoView(Object item, DataGridColumn column) in C:\Downloads\DataGridCTPSample\DataGridCTPSample\Toolkit-release\DataGrid\Microsoft\Windows\Controls\DataGrid.cs:line 1242
       at Microsoft.Windows.Controls.DataGrid.OnCurrentCellChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) in C:\Downloads\DataGridCTPSample\DataGridCTPSample\Toolkit-release\DataGrid\Microsoft\Windows\Controls\DataGrid.cs:line 2139
       at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
       at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
       at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
       at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, OperationType operationType)
       at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, OperationType operationType, Boolean isInternal)
       at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
       at Microsoft.Windows.Controls.DataGrid.set_CurrentCell(DataGridCellInfo value) in C:\Downloads\DataGridCTPSample\DataGridCTPSample\Toolkit-release\DataGrid\Microsoft\Windows\Controls\DataGrid.cs:line 2082
       at Microsoft.Windows.Controls.DataGrid.OnCurrentItemChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) in C:\Downloads\DataGridCTPSample\DataGridCTPSample\Toolkit-release\DataGrid\Microsoft\Windows\Controls\DataGrid.cs:line 2036
       at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
       at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
       at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
       at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, OperationType operationType)
       at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, OperationType operationType, Boolean isInternal)
       at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
       at Microsoft.Windows.Controls.DataGrid.set_CurrentItem(Object value) in C:\Downloads\DataGridCTPSample\DataGridCTPSample\Toolkit-release\DataGrid\Microsoft\Windows\Controls\DataGrid.cs:line 2018
       at Microsoft.Windows.Controls.DataGrid.OnExecutedBeginEdit(ExecutedRoutedEventArgs e) in C:\Downloads\DataGridCTPSample\DataGridCTPSample\Toolkit-release\DataGrid\Microsoft\Windows\Controls\DataGrid.cs:line 1539
       at Microsoft.Windows.Controls.DataGrid.OnExecutedBeginEdit(Object sender, ExecutedRoutedEventArgs e) in C:\Downloads\DataGridCTPSample\DataGridCTPSample\Toolkit-release\DataGrid\Microsoft\Windows\Controls\DataGrid.cs:line 1492
       at System.Windows.Input.CommandBinding.OnExecuted(Object sender, ExecutedRoutedEventArgs e)
       at System.Windows.Input.CommandManager.ExecuteCommandBinding(Object sender, ExecutedRoutedEventArgs e, CommandBinding commandBinding)
       at System.Windows.Input.CommandManager.FindCommandBinding(CommandBindingCollection commandBindings, Object sender, RoutedEventArgs e, ICommand command, Boolean execute)
       at System.Windows.Input.CommandManager.FindCommandBinding(Object sender, RoutedEventArgs e, ICommand command, Boolean execute)
       at System.Windows.Input.CommandManager.OnExecuted(Object sender, ExecutedRoutedEventArgs e)
       at System.Windows.UIElement.OnExecutedThunk(Object sender, ExecutedRoutedEventArgs e)
       at System.Windows.Input.ExecutedRoutedEventArgs.InvokeEventHandler(Delegate genericHandler, Object target)
       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.RoutedCommand.ExecuteImpl(Object parameter, IInputElement target, Boolean userInitiated)
       at System.Windows.Input.RoutedCommand.Execute(Object parameter, IInputElement target)
       at Microsoft.Windows.Controls.DataGrid.BeginEdit(RoutedEventArgs editingEventArgs) in C:\Downloads\DataGridCTPSample\DataGridCTPSample\Toolkit-release\DataGrid\Microsoft\Windows\Controls\DataGrid.cs:line 2336
       at Microsoft.Windows.Controls.DataGridColumn.BeginEdit(InputEventArgs e) in C:\Downloads\DataGridCTPSample\DataGridCTPSample\Toolkit-release\DataGrid\Microsoft\Windows\Controls\DataGridColumn.cs:line 1161
       at Microsoft.Windows.Controls.DataGridTextColumn.OnInput(InputEventArgs e) in C:\Downloads\DataGridCTPSample\DataGridCTPSample\Toolkit-release\DataGrid\Microsoft\Windows\Controls\DataGridTextColumn.cs:line 182
       at Microsoft.Windows.Controls.DataGridCell.SendInputToColumn(InputEventArgs e) in C:\Downloads\DataGridCTPSample\DataGridCTPSample\Toolkit-release\DataGrid\Microsoft\Windows\Controls\DataGridCell.cs:line 730
       at Microsoft.Windows.Controls.DataGridCell.OnTextInput(TextCompositionEventArgs e) in C:\Downloads\DataGridCTPSample\DataGridCTPSample\Toolkit-release\DataGrid\Microsoft\Windows\Controls\DataGridCell.cs:line 692
       at System.Windows.UIElement.OnTextInputThunk(Object sender, TextCompositionEventArgs e)
       at System.Windows.Input.TextCompositionEventArgs.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.TextCompositionManager.UnsafeCompleteComposition(TextComposition composition)
       at System.Windows.Input.TextCompositionManager.PostProcessInput(Object sender, ProcessInputEventArgs e)
       at System.Windows.Input.InputManager.ProcessStagingArea()
       at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
       at System.Windows.Input.TextCompositionManager.UnsafeStartComposition(TextComposition composition)
       at System.Windows.Input.TextCompositionManager.PostProcessInput(Object sender, ProcessInputEventArgs e)
       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.HwndKeyboardInputProvider.ProcessTextInputAction(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       at System.Windows.Interop.HwndSource.OnPreprocessMessage(Object param)
       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 System.Windows.Interop.HwndSource.OnPreprocessMessageThunk(MSG& msg, Boolean& handled)
       at System.Windows.Interop.HwndSource.WeakEventPreprocessMessage.OnPreprocessMessage(MSG& msg, Boolean& handled)
       at System.Windows.Interop.ThreadMessageEventHandler.Invoke(MSG& msg, Boolean& handled)
       at System.Windows.Interop.ComponentDispatcherThread.RaiseThreadMessage(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()
       at DataGridCTPSample.App.Main() in C:\Downloads\DataGridCTPSample\DataGridCTPSample\DataGridCTPSample\obj\Debug\App.g.cs:line 0
       at System.AppDomain._nExecuteAssembly(Assembly 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)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException:

Coordinator
Aug 13, 2008 at 11:26 PM
This issue happens when SelectionUnit == Cell and openning a new row for edit.  This issue has been logged. 

Thanks,
Vince
Jun 14, 2010 at 9:17 PM
Last week I run against the same exception. I use VS 2010 final with a .net 4.0 project and wpf datagrid. Why is the bug not fixed after 2 years?
Jun 15, 2010 at 1:45 PM

I just did a mild dummy spit about some other datagrid bugs on another forum. It's incomprehensible that some of these basic bugs aren't fixed yet.  Wish I'd never invested the time in using it. Would have been better to write my own simpler datagrid using a ListBox. This is no fun. And little money when the learning curve for WPF is steep anyway. I hadn't allowed for the development software being buggy this late in the game. I am using WPF 4 and VS 2010.

Jun 17, 2010 at 3:02 PM

My uninformed theory is that whoever decided to release the WPF Toolkit stuff (at least the DataGrid) in .NET 4 wasn't on board with Microsoft's Quality Bands concept.  And/or they just can't get anyone to work on the difficult and unpleasant bugfixing of code from other employees that have since moved on, there isn't any investment/commitment in this area from the higher ups, etc.

According to this page, the Feb. 2010 release of DataGrid is considered to be in the Stable quality band:
http://wpf.codeplex.com/releases/view/40535

According to this page, this means it's not ready for full release and is not mature:
http://wpf.codeplex.com/wikipage?title=Quality%20Bands

Then again, these definitions imply that the bar for fixing bugs in DataGrid is (was?!) relatively low, so go figure eh. :)

Maybe they were inspired by these guys (2:25-2:40):
http://www.youtube.com/watch?v=PFZ39nQ_k90

Nov 30, 2010 at 6:59 PM

When will this be fixed? How can I vote to make this bug a higher priority?