WPF XAML error "Cannot be null parameter name root" - wpf

In Visual Studio 2015, I am trying to create a XAML control from an existing base class in my project, but I'm getting the error shown below. What's wrong?
error screenshot
Here's a bit more information:
at Ninject.ResolutionExtensions.GetResolutionIterator(IResolutionRoot root, Type service, Func`2 constraint, IEnumerable`1 parameters, Boolean isOptional, Boolean isUnique)
at Ninject.ResolutionExtensions.Get[T](IResolutionRoot root, IParameter[] parameters)
at Render.Core.Models.ModelBase.get_Project()
at Render.Core.Models.ModelBase.get_Interface()
at Render.Core.Models.StaticModelBase.get_Interface()
at Render.Core.RenderControls.RenderHeader..ctor(String title, ContentControl image, Boolean isAdminHome)
at Render.MainApplication.Views.Shared.ViewBase.CalcSize()
at Render.MainApplication.Views.Shared.ViewBase.ViewBase_SizeChanged(Object sender, SizeChangedEventArgs e)
at System.Windows.SizeChangedEventArgs.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 e)
at System.Windows.FrameworkElement.OnRenderSizeChanged(SizeChangedInfo sizeInfo)
at System.Windows.ContextLayoutManager.fireSizeChangedEvents()
at System.Windows.ContextLayoutManager.UpdateLayout()
at System.Windows.UIElement.UpdateLayout()
Apparently the problem is related to Ninject. Maybe I need to include some kind of namespace declaration for that?

Related

Silverlight Application throwing Null reference Exception on clearing list which is bound to Grid

In Silverlight Application I have bound one ObservableCollection to Grid.
But when I edit row of grid,I am saving updated data in db and clear observable collection of grid and reinsert new values in it.
but when I try to clear observable collection it is throwing an error "Object reference not set to an instance of an object"
Am I missing Anything here.
Code:
MyList.Clear();
StackTrace of Exception
at
Infragistics.AutomationPeers.CellsPanelAutomationPeer.Row_PropertyChanged(Object
sender, PropertyChangedEventArgs e)\r\n at
System.ComponentModel.PropertyChangedEventHandler.Invoke(Object
sender, PropertyChangedEventArgs e)\r\n at
Infragistics.RecyclingContainer1.OnPropertyChanged(String name)\r\n
at Infragistics.Controls.Grids.Row.SetSelected(Boolean isSelected)\r\n
at
Infragistics.Controls.Grids.Row.Infragistics.ISelectableObject.SetSelected(Boolean
isSelected)\r\n at
Infragistics.Controls.Grids.SelectedCollectionBase1.InternalRemoveItemSilently(Int32
index)\r\n at
Infragistics.Controls.Grids.SelectedCollectionBase1.RemoveItem(Int32
index)\r\n at Infragistics.Collections.CollectionBase1.Remove(T
item)\r\n at
Infragistics.Controls.Grids.RowsManager.InvalidateSelectionAndActivation(Boolean
validateInList, Boolean invalidateSelection)\r\n at
Infragistics.Controls.Grids.RowsManager.InvalidateItemSource(Boolean
invalidateSelection)\r\n at
Infragistics.Controls.Grids.RowsManager.DataManager_CollectionChanged(Object
sender, NotifyCollectionChangedEventArgs e)\r\n at
Infragistics.DataManagerBase.OnCollectionChanged(NotifyCollectionChangedEventArgs
e)\r\n at
Infragistics.DataManagerBase.OnDataSourceCollectionChanged(NotifyCollectionChangedEventArgs
e)\r\n at
Infragistics.DataManager1.OnDataSourceCollectionChanged(NotifyCollectionChangedEventArgs
e)\r\n at
Infragistics.DataManagerBase.DataSource_CollectionChanged(Object
sender, NotifyCollectionChangedEventArgs e)\r\n at
System.Collections.ObjectModel.ObservableCollection1.OnCollectionChanged(NotifyCollectionChangedEventArgs
e)\r\n at
System.Collections.ObjectModel.ObservableCollection1.ClearItems()\r\n
at System.Collections.ObjectModel.Collection1.Clear()\r\n at

WPF Crash not in our code

Does anyone know how to solve a crash in WPF where the call stack is completely in windows code.
Following is the call stack...
6/26/2014 3:29:05 PM: [FATAL] System.InvalidOperationException: Specified element is already the logical child of another element. Disconnect it first.
at System.Windows.FrameworkElement.ChangeLogicalParent(DependencyObject newParent)
at System.Windows.FrameworkElement.AddLogicalChild(Object child)
at System.Windows.Controls.ContentControl.OnContentChanged(Object oldContent, Object newContent)
at System.Windows.Controls.TabItem.OnContentChanged(Object oldContent, Object newContent)
at System.Windows.Controls.ContentControl.OnContentChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
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, Boolean coerceWithCurrentValue, OperationType operationType)
at System.Windows.StyleHelper.ApplyStyleOrTemplateValue(FrameworkObject fo, DependencyProperty dp)
at System.Windows.StyleHelper.InvalidateContainerDependents(DependencyObject container, FrugalStructList1& exclusionContainerDependents, FrugalStructList1& oldContainerDependents, FrugalStructList`1& newContainerDependents)
at System.Windows.StyleHelper.DoStyleInvalidations(FrameworkElement fe, FrameworkContentElement fce, Style oldStyle, Style newStyle)
at System.Windows.StyleHelper.UpdateStyleCache(FrameworkElement fe, FrameworkContentElement fce, Style oldStyle, Style newStyle, Style& styleCache)
at System.Windows.FrameworkElement.OnStyleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
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, Boolean coerceWithCurrentValue, OperationType operationType)
at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
at System.Windows.Controls.ItemsControl.ApplyItemContainerStyle(DependencyObject container, Object item)
at System.Windows.Controls.ItemsControl.MS.Internal.Controls.IGeneratorHost.PrepareItemContainer(DependencyObject container, Object item)
at System.Windows.Controls.ItemContainerGenerator.System.Windows.Controls.Primitives.IItemContainerGenerator.PrepareItemContainer(DependencyObject container)
at System.Windows.Controls.Panel.GenerateChildren()
at System.Windows.Controls.Panel.OnItemsChangedInternal(Object sender, ItemsChangedEventArgs args)
at System.Windows.Controls.Panel.OnItemsChanged(Object sender, ItemsChangedEventArgs args)
at System.Windows.Controls.ItemContainerGenerator.OnRefresh()
at System.Windows.Controls.ItemContainerGenerator.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)
at System.Windows.Controls.ItemContainerGenerator.System.Windows.IWeakEventListener.ReceiveWeakEvent(Type managerType, Object sender, EventArgs e)
at System.Windows.WeakEventManager.DeliverEventToList(Object sender, EventArgs args, ListenerList list)
at System.Windows.WeakEventManager.DeliverEvent(Object sender, EventArgs args)
at System.Collections.Specialized.CollectionChangedEventManager.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)
at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
at System.Windows.Data.CollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args)
at System.Windows.Controls.ItemCollection.SetCollectionView(CollectionView view)
at System.Windows.Controls.ItemCollection.SetItemsSource(IEnumerable value)
at System.Windows.Controls.ItemsControl.OnItemsSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
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, Boolean coerceWithCurrentValue, OperationType operationType)
at System.Windows.DependencyObject.InvalidateProperty(DependencyProperty dp)
at System.Windows.Data.BindingExpressionBase.Invalidate(Boolean isASubPropertyChange)
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.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)
You're getting this error because you are trying to set a control (Visual) as the child of another Visual without first removing it from the visual tree. A Visual can never be in the visual tree in two places.
The difficult part is going to be tracking down what Visual is being inserted into the tree twice. You're going to have a really hard time catching it in the debugger (think nearly impossible), so you'll have to try some more creative debugging methods. If you can reproduce the problem consistently, maybe try stripping Visuals out one at a time and see which Visual is causing the problem that way. If you have some custom controls that are working with some lower level visual tree functionality, these are going to be highly suspect. Take a look at them first.

Assigning x:Name to Thickness throws exception

Can anyone explain why this throws an exception?
<UserControl>
<Grid>
<Grid.Margin>
<Thickness x:Name="thickness" />
</Grid.Margin>
</Grid>
</UserControl>
If I remove the x:Name attribute, then it runs successfully.
Error details:
Message: Unhandled Error in Silverlight Application
Code: 4004
Category: ManagedRuntimeError
Message: System.NullReferenceException: Object reference not set to an instance of an object.
at SilverlightBindingTest.MainPage.InitializeComponent()
at SilverlightBindingTest.MainPage..ctor()
at SilverlightBindingTest.App.Application_Startup(Object sender, StartupEventArgs e)
at MS.Internal.CoreInvokeHandler.InvokeEventHandler(UInt32 typeIndex, Delegate handlerDelegate, Object sender, Object args)
at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName, UInt32 flags)
The Name attribute is a DependencyObject and as such can only be set on another DependencyObject.
Thickness is not a DependencyObject, so you cannot use the Name attribute.

Object not set to an instance of an object when editing a WPF datagrid combobox column when the column is sorted

I have a Datagrid in which I use a TextColumn bound to an Integer Property.I can edit the the values in the TextColumn allright until I click the column header. The column will sort correctly when clicked but when I then try to edit a value afterwards I get an exception when I cause a LostFocus Event by clicking somewhere else.
(Question changed to the minimal required setup to make it reproducible)
The XAML:
<DataGridTextColumn Binding="{Binding CompStrength}"/>
The StackTrace:
bij System.Windows.Controls.DataGrid.UpdateRowEditing(DataGridCell cell)
bij System.Windows.Controls.DataGrid.OnExecutedCommitEdit(ExecutedRoutedEventArgs e)
bij System.Windows.Controls.DataGrid.OnExecutedCommitEdit(Object sender, ExecutedRoutedEventArgs e)
bij System.Windows.Input.CommandBinding.OnExecuted(Object sender, ExecutedRoutedEventArgs e)
bij System.Windows.Input.CommandManager.ExecuteCommandBinding(Object sender, ExecutedRoutedEventArgs e, CommandBinding commandBinding)
bij System.Windows.Input.CommandManager.FindCommandBinding(CommandBindingCollection commandBindings, Object sender, RoutedEventArgs e, ICommand command, Boolean execute)
bij System.Windows.Input.CommandManager.FindCommandBinding(Object sender, RoutedEventArgs e, ICommand command, Boolean execute)
bij System.Windows.Input.CommandManager.OnExecuted(Object sender, ExecutedRoutedEventArgs e)
bij System.Windows.UIElement.OnExecutedThunk(Object sender, ExecutedRoutedEventArgs e)
bij System.Windows.Input.ExecutedRoutedEventArgs.InvokeEventHandler(Delegate genericHandler, Object target)
bij System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
bij System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
bij System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
bij System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
bij System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
bij System.Windows.Input.RoutedCommand.ExecuteImpl(Object parameter, IInputElement target, Boolean userInitiated)
bij System.Windows.Input.RoutedCommand.Execute(Object parameter, IInputElement target)
bij System.Windows.Controls.DataGrid.EndEdit(RoutedCommand command, DataGridCell cellContainer, DataGridEditingUnit editingUnit, Boolean exitEditMode)
bij System.Windows.Controls.DataGrid.OnCurrentCellChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
bij System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
bij System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
bij System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
bij System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
bij System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
bij System.Windows.DependencyObject.SetCurrentValueInternal(DependencyProperty dp, Object value)
bij System.Windows.Controls.DataGrid.set_CurrentCellContainer(DataGridCell value)
bij System.Windows.Controls.DataGrid.set_FocusedCell(DataGridCell value)
bij System.Windows.Controls.DataGridCell.OnAnyGotFocus(Object sender, RoutedEventArgs e)
bij System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
bij System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
bij System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
bij System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
bij System.Windows.FrameworkElement.OnGotFocus(RoutedEventArgs e)
I finally tracked down the cause for this exception after painstakingly rebuilding the project: Surprisingly the error appears after adding the classc.xaml theme from PresentationFramework.Classic.dll as a resource to the WPF project.
I contacted Microsoft about this en we'll see what happens...
Actually I found the problem in my own case is in a callback from CellEditEnding event handler was trying to update grid data source, which caused the behavior. Add a flag to notice grid is being updated solved my problem

Unable to cast object of type 'MS.Internal.NamedObject' to custom type

I am not new to WPF, but I can't figure out this problem:
I use an ObservableCollection<MyCustomType> that i bind to ComboBoxes, it's all working great as usual, but at some point i need to change the content of the collection (i retrieve a new set from the database, that may or may not contain part of the old one).
Now adding or removing elements is all done by WPF, but if you change the whole collection I found you had to raise PropertyChanged for the collection.
The problem is that sometimes it crashes giving me a not-so-friendly exception.
I'm unsure of what exactly triggers the crash, but if I don't touch the View and retrieve a new set from DB, it doesn't crash.
Here is some code:
public const string MyObsCollectionProperty = "MyObsCollection";
private ObservableCollection<MyCustomType> m_MyObsCollection;
public ObservableCollection<MyCustomType> MyObsCollection
{
get { return m_MyObsCollection; }
set
{
m_MyObsCollection = value;
RaisePropertyChanged(MyObsCollectionProperty); // <-- Crashes here
}
}
I get the exception: Unable to cast object of type 'MS.Internal.NamedObject' to type 'MyNameSpace.MyCustomType'
Please note that this exception comes from Prism, but it's probably just because i inherit from NotificationObject on my ViewModel.
I appreciate any help on this problem,
Regards,
LK.
EDIT: I think the problem comes from the ComboBox, and more specifically, from the way i set their properties.
I bind the ItemsSource property to an ObservableCollection, and to decide which element to select, I bind the SelectedValue to a field of an item of an ObservableCollection (the ComboBox is nested within a ListView).
I also set SelectedValuePath (you get the idea).
I guess when i change the first collection hell breaks lose on that setup. And it leaves it in peace when i don't touch the view because of virtualization (it is hidden at first).
ADDITION:
The InnerException is nulll.
Message: Unable to cast object of type 'MS.Internal.NamedObject' to type 'CocoonV4.DAL.WcfServiceCocoonV4.DekoTemplate'.
at Microsoft.Practices.Prism.Commands.DelegateCommand`1.<>c__DisplayClass6.<.ctor>b__3(Object o)
at Microsoft.Practices.Prism.Commands.DelegateCommandBase.CanExecute(Object parameter)
at Microsoft.Practices.Prism.Commands.DelegateCommandBase.System.Windows.Input.ICommand.CanExecute(Object parameter)
at System.Windows.Interactivity.InvokeCommandAction.Invoke(Object parameter)
at System.Windows.Interactivity.TriggerBase.InvokeActions(Object parameter)
at System.Windows.Interactivity.EventTriggerBase.OnEvent(EventArgs eventArgs)
at System.Windows.Interactivity.EventTriggerBase.OnEventImpl(Object sender, EventArgs eventArgs)
at System.Windows.Controls.SelectionChangedEventArgs.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 e)
at System.Windows.Controls.ComboBox.OnSelectionChanged(SelectionChangedEventArgs e)
at System.Windows.Controls.Primitives.Selector.InvokeSelectionChanged(List`1 unselectedItems, List`1 selectedItems)
at System.Windows.Controls.Primitives.Selector.SelectionChanger.End()
at System.Windows.Controls.Primitives.Selector.OnItemsChanged(NotifyCollectionChangedEventArgs e)
at System.Windows.Controls.ItemsControl.OnItemCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
at System.Windows.Data.CollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args)
at System.Windows.Controls.ItemCollection.System.Windows.IWeakEventListener.ReceiveWeakEvent(Type managerType, Object sender, EventArgs e)
at System.Windows.WeakEventManager.DeliverEventToList(Object sender, EventArgs args, ListenerList list)
at System.Windows.WeakEventManager.DeliverEvent(Object sender, EventArgs args)
at System.Collections.Specialized.CollectionChangedEventManager.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)
at System.Windows.Data.CollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args)
at System.Windows.Data.ListCollectionView.RefreshOverride()
at System.Windows.Data.CollectionView.RefreshOrDefer()
at System.Windows.Data.ListCollectionView.ProcessCollectionChanged(NotifyCollectionChangedEventArgs args)
at System.Windows.Data.CollectionView.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)
at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
at System.Collections.ObjectModel.ObservableCollection`1.ClearItems()
at System.Collections.ObjectModel.Collection`1.Clear()
at CocoonV4.Modules.CocoonViewsVMs.ManageTemplateDekocastViewModel.SetAllowedDekos(IEnumerable`1 _NewAllowedDekos) in C:\Users\lkottmann\Documents\Visual Studio 2010\Projects\IAV-Cocoon\MAIN\CocoonV4\CocoonV4.Modules.RunningItem\CocoonViewsVMs\ManageTemplateDekocastViewModel.cs:line 83
at CocoonV4.Modules.CocoonViewsVMs.ManageTemplateDekocastViewModel.LoadTemplates(Nullable`1 param) in C:\Users\lkottmann\Documents\Visual Studio 2010\Projects\IAV-Cocoon\MAIN\CocoonV4\CocoonV4.Modules.RunningItem\CocoonViewsVMs\ManageTemplateDekocastViewModel.cs:line 128
at Microsoft.Practices.Prism.Commands.DelegateCommand`1.<>c__DisplayClass6.<.ctor>b__2(Object o)
at Microsoft.Practices.Prism.Commands.DelegateCommandBase.Execute(Object parameter)
at Microsoft.Practices.Prism.Commands.DelegateCommandBase.System.Windows.Input.ICommand.Execute(Object parameter)
at System.Windows.Interactivity.InvokeCommandAction.Invoke(Object parameter)
at System.Windows.Interactivity.TriggerBase.InvokeActions(Object parameter)
at System.Windows.Interactivity.EventTriggerBase.OnEvent(EventArgs eventArgs)
at System.Windows.Interactivity.EventTriggerBase.OnEventImpl(Object sender, EventArgs eventArgs)
at System.Windows.Controls.SelectionChangedEventArgs.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 e)
at System.Windows.Controls.ComboBox.OnSelectionChanged(SelectionChangedEventArgs e)
at System.Windows.Controls.Primitives.Selector.InvokeSelectionChanged(List`1 unselectedItems, List`1 selectedItems)
at System.Windows.Controls.Primitives.Selector.SelectionChanger.End()
at System.Windows.Controls.Primitives.Selector.SelectionChanger.SelectJustThisItem(Object item, Boolean assumeInItemsCollection)
at System.Windows.Controls.ComboBox.NotifyComboBoxItemMouseUp(ComboBoxItem comboBoxItem)
at System.Windows.Controls.ComboBoxItem.OnMouseLeftButtonUp(MouseButtonEventArgs e)
at System.Windows.UIElement.OnMouseLeftButtonUpThunk(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.OnMouseUpThunk(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.RaiseTrustedEvent(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, WindowMessage 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, 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 CocoonV4.App.Main() in C:\Users\lkottmann\Documents\Visual Studio 2010\Projects\IAV-Cocoon\MAIN\CocoonV4\CocoonV4\obj\x86\Debug\App.g.cs:line 0
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()
More EDIT:
I isolated the problem to a single ComboBox declarated as follow:
<custom:CComboBox x:Name="cmbFirstDko"
ItemsSource="{Binding Path=DataContext.MyFirstCollection, ElementName=myViewName}"
SelectedValue="{Binding anObjectID, Mode=TwoWay}"
SelectedValuePath="anObjectID">
Please note that the anObjectID property in SelectedValue comes from the ListView's DataContext (this ComboBox is displaying part of an item of that ListView), whereas the anObjectID in SelectedValuePath refers to a property that each item in DataContext.MyFirstCollection has.
This allows me to select a different ComboBoxItem for each element of the ListView.
I hope my explanation is clear, otherwise tell me in the comments and i'll try to clarify.
Breakthrough:
The ComboBoxes have their DataContext set to {DisconnectedItem}, this is the result of the work of so-called SentinelObjects which intervene when there's a binding between 2 collections, as in my example.
It is actually officialy a bug of the framework, and it has been fixed for the next version, see this MS Bug Page
Does anyone know of a workaround?
EDIT:
There used to be an answer linking to my blog, but while I move it people downvoted the answer. I got sick of it so now it'll be back when it's ready.
No need to call RaisePropertyChanged for MyObsCollection, because ObservableCollection internal implements INotifiyProperty Changed.
I think it is Crashing while assign the value(during set call), this will happen when you try to assign a collection of one type collection of another type. You have to create object of the MyCustomType and should be added to the MyObsCollection instead of directly assigning a collection of different type to MyObsCollection
It would be great if could post the entire code or piece of code where u assign the or add objects to MyObsCollection
I've the same problem just now, and after I remove the static-ressource Style on the ItemContainerStyle and define it directly beneath ListBox, the problem went away.
I had x:Name property on the elements in DataTemplate, and since I deleted them, the compilator didn't make it at all, probably. So I changed a way at all to make it sense.
Hope this small trick will help you !

Resources