无法将类型为“MS.Internal.NamedObject”的对象转换为自定义类型 [英] Unable to cast object of type 'MS.Internal.NamedObject' to custom type
问题描述
我不是新的WPF,但我不能弄清楚这个问题:
我使用 ObservableCollection< MyCustomType> code>,我绑定到
ComboBox
es,它的所有工作很好像往常一样,但在某些时候,我需要更改集合的内容(我检索一个新的从数据库设置,可能包含或可能不包含旧部分)。
现在添加或删除元素都由WPF完成,但如果您更改整个集合我发现你不得不为集合调用PropertyChanged。
问题是有时候会崩溃给我一个不太友好的异常。
我不确定触发崩溃的原因,但如果我不触摸视图并从DB检索新集合,它不会崩溃。
这里是一些代码:
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
}
}
exception:无法将类型为MS.Internal.NamedObject的对象转换为类型MyNameSpace.MyCustomType
请注意,这个异常来自Prism,但它可能只是因为我从我的ViewModel的NotificationObject继承。
我感谢任何关于这个问题的帮助,
尊敬,
LK。
/ strong>我认为问题来自ComboBox,更具体地说,从我设置它们的属性的方式。
我将ItemsSource属性绑定到一个ObservableCollection,决定要选择哪个元素,我将SelectedValue绑定到一个ObservableCollection的一个项的字段(ComboBox嵌套在ListView中)。
我也设置了SelectedValuePath(你得到了想法)。
我想当我改变第一个收集地狱打破了失败的设置。
ADDITION: / p>
InnerException是nulll。
讯息: 无法投射类型为MS.Internal.NamedObject的物件来输入「CocoonV4.DAL」。 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参数)
在System.Windows.Interactivity.InvokeCommandAction.Invoke(对象参数)
在System.Windows.Interactivity.TriggerBase.InvokeActions(对象参数)
在System.Windows.Interactivity.EventTriggerBase.OnEvent(EventArgs eventArgs)
在System.Windows.Interactivity.EventTriggerBase.OnEventImpl(对象发件人,EventArgs eventArgs)
在System.Windows.Controls.SelectionChangedEventArgs .InvokeEventHandler(delegate genericHandler,Object genericTarget)
在System.Windows.RoutedEventArgs.InvokeHandler(代理处理程序,对象目标)
在System.Windows.RoutedEventHandlerInfo.InvokeHandler(对象目标,RoutedEventArgs routedEventArgs)
在System.Windows.EventRoute.InvokeHandlersImpl(对象源,RoutedEventArgs参数,布尔值reRaised)
在System.Windows.UIElement.RaiseEventImpl(DependencyObject发送方,RoutedEventArgs args)
在System.Windows.UIElement.RaiseEvent (RoutedEventArgs e)
在System.Windows.Controls.ComboBox.OnSelectionChanged(SelectionChangedEventArgs e)
在System.Windows.Controls.Primitives.Selector.InvokeSelectionChanged(List`1 unselectedItems,List`1 selectedItems)
在System.Windows.Controls.Primitives.Selector.SelectionChanger.End()
在System.Windows.Controls.Primitives.Selector.OnItemsChanged(NotifyCollectionChangedEventArgs e)
在System.Windows.Controls。 ItemControl.OnItemCollectionChanged(Object sender,NotifyCollectionChangedEventArgs e)
在System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender,NotifyCollectionChangedEventArgs e)
在System.Windows.Data.CollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args)
at System.Windows.Controls.ItemCollection.System.Windows.IWeakEventListener.ReceiveWeakEvent(type managerType,Object sender,EventArgs e)
在System.Windows.WeakEventManager.DeliverEventToList(Object sender,EventArgs args,ListenerList list )
在System.Windows.WeakEventManager.DeliverEvent(Object sender,EventArgs args)
在System.Collections.Specialized.CollectionChangedEventManager.OnCollectionChanged(对象发件人,NotifyCollectionChangedEventArgs args)
在System.Windows。 Data.CollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args)
在System.Windows.Data.ListCollectionView.RefreshOverride()
在System.Windows.Data.CollectionView.RefreshOrDefer()
在System.Windows。 Data.ListCollectionView.ProcessCollectionChanged(NotifyCollectionChangedEventArgs args)
在System.Windows.Data.CollectionView.OnCollectionChanged(对象发件人,NotifyCollectionChangedEventArgs args)
在System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
在System.Collections.ObjectModel.ObservableCollection`1.ClearItems()
在System.Collections.ObjectModel.Collection`1.Clear()
在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)
在Microsoft.Practices.Prism.Commands.DelegateCommandBase.Execute(对象参数)
在Microsoft.Practices.Prism.Commands.DelegateCommandBase.System.Windows.Input.ICommand。在System.Windows.Interactivity.TriggerBase.InvokeActions(对象参数)中
在System.Windows中
在System.Windows.Interactivity.InvokeCommandAction.Invoke(对象参数)
。 Interactivity.EventTriggerBase.OnEvent(EventArgs eventArgs)
在System.Windows.Interactivity.EventTriggerBase.OnEventImpl(Object sender,EventArgs eventArgs)
在System.Windows.Controls.SelectionChangedEventArgs.InvokeEventHandler(Delegate genericHandler,Object genericTarget )
在System.Windows.RoutedEventArgs.InvokeHandler(代理处理程序,对象目标)
在System.Windows.RoutedEventHandlerInfo.InvokeHandler(对象目标,RoutedEventArgs routedEventArgs)
在System.Windows.EventRoute。 InvokeHandlersImpl(Object source,RoutedEventArgs args,Boolean reRaised)
在System.Windows.UIElement.RaiseEventImpl(DependencyObject sender,RoutedEventArgs args)
在System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
在System.Windows.Controls.ComboBox.OnSelectionChanged(SelectionChangedEventArgs e)
在System.Windows.Controls.Primitives.Selector.InvokeSelectionChanged(List`1 unselectedItems,List`1 selectedItems)
在System.Windows。 Controls.Primitives.Selector.SelectionChanger.End()
在System.Windows.Controls.Primitives.Selector.SelectionChanger.SelectJustThisItem(对象项目,布尔值assumeInItemsCollection)
在System.Windows.Controls.ComboBox.NotifyComboBoxItemMouseUp (ComboBoxItem comboBoxItem)
在System.Windows.Controls.ComboBoxItem.OnMouseLeftButtonUp(MouseButtonEventArgs e)
在System.Windows.UIElement.OnMouseLeftButtonUpThunk(对象发件人,MouseButtonEventArgs e)
在System.Windows。 Input.MouseButtonEventArgs.InvokeEventHandler(delegate genericHandler,Object genericTarget)
在System.Windows.RoutedEventArgs.InvokeHandler(代理处理程序,对象目标)
在System.Windows.RoutedEventHandlerInfo.InvokeHandler(对象目标,RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source,RoutedEventArgs args,Boolean reRaised)
在System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender,RoutedEventArgs args,RoutedEvent newEvent)
at System .Windows.UIElement.OnMouseUpThunk(Object sender,MouseButtonEventArgs e)
在System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(委托genericHandler,对象genericTarget)
在System.Windows.RoutedEventArgs.InvokeHandler(委托处理程序,对象目标)
在System.Windows.RoutedEventHandlerInfo.InvokeHandler(对象目标,RoutedEventArgs routedEventArgs)
在System.Windows.EventRoute.InvokeHandlersImpl(对象源,RoutedEventArgs args,布尔值reRaised)
在系统.Windows.UIElement.RaiseEventImpl(DependencyObject sender,RoutedEventArgs args)
在System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
在System.Windows.UIElement.RaiseEvent(RoutedEventArgs args,布尔值信任)
在System.Windows.Input.InputManager.ProcessStagingArea()
在System.Windows.Input.InputManager.ProcessInput(InputEventArgs输入)
在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)
在System.Windows.Interop.HwndMouseInputProvider.FilterMessage (IntPtr hwnd,WindowMessage msg,IntPtr wParam,IntPtr lParam,Boolean&处理)
在MS.Win32.HwndWrapper.WndProc处的System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd,Int32 msg,IntPtr wParam,IntPtr lParam,Boolean& processed)
IntPtr hwnd,Int32 msg,IntPtr wParam,IntPtr lParam,Boolean& processed)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
在System.Windows.Threading.ExceptionWrapper.InternalRealCall(委托回调,Object args,Int32 (System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority,numArgs))
在MS.Internal.Threading.Threading.ExceptionFilterHelper.TryCatchWhen(对象源,代理方法,对象args,Int32 numArgs,委托catchHandler)在MS.Win32.UnsafeNativeMethods.DispatchMessage()中的
,在MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd,Int32 msg,IntPtr wParam,IntPtr lParam)的
中的TimeSpan超时,Delegate方法,Object args,Int32 numArgs) MSG& msg)
在System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame框架)
在System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame框架)
在System.Windows.Application .RunDispatcher(Object ignore)
在System.Windows.Application.RunInternal(窗口窗口)
在System.Windows.Application.Run(窗口窗口)
在System.Windows.Application.Run ()
在CocoonV4.App.Main()在C:\Users\lkottmann\Documents\Visual Studio 2010\Projects\IAV-Cocoon\MAIN\CocoonV4\CocoonV4\ obj \x86 \Debug \App.g.cs:line 0
在System.AppDomain._nExecuteAssembly(RuntimeAssembly程序集,String [] args)
在System.AppDomain.ExecuteAssembly(String assemblyFile,证书assemblySecurity,String [] args)
在Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
在System.Threading.ThreadHelper.ThreadStart_Context(对象状态)
在System.Threading.ExecutionContext .Run(ExecutionContext executionContext,ContextCallback callback,Object state,Boolean ignoreSyncCtx)
在System.Threading.ExecutionContext.Run(ExecutionContext executionContext,ContextCallback回调,对象状态)
在System.Threading.ThreadHelper.ThreadStart )
更多编辑:
我将问题分离到单个ComboBox,如下所示:
< custom:CComboBox x:Name = cmbFirstDko
ItemsSource ={Binding Path = DataContext.MyFirstCollection,ElementName = myViewName}
SelectedValue ={Binding anObjectID,Mode = TwoWay}
SelectedValuePath =anObjectID>
请注意, anObjectID
code> SelectedValue 来自 ListView
的DataContext(此ComboBox显示该ListView的一个项目的一部分) code> 中的每个项目的属性指定
中的每个项目的属性
c>。
这允许我为ListView的每个元素选择不同的ComboBoxItem。
希望我的解释清楚,否则在评论中告诉我,我会尝试澄清。
突破:
ComboBoxes将它们的DataContext设置为{DisconnectedItem},这是所谓的SentinelObject的工作的结果,当两个集合之间有绑定时,如在我的例子中那样。
它实际上是一个框架的错误,它已经修复了下一个版本,请参阅 有人知道解决方法吗? 编辑: 我刚才也有同样的问题,我删除了ItemContainerStyle上的静态方法,然后直接在ListBox下面定义它。问题消失了。 我有DataTemplate元素的x:Name属性,因为我删除它们,编译器根本没有做,可能。所以我改变了一个方法,使它有意义。 希望这个小把戏会帮助你! I am not new to WPF, but I can't figure out this problem: I use an 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. Here is some code: I get the exception: 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 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: More EDIT: I isolated the problem to a single ComboBox declarated as follow: Please note that the 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. 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 ! 这篇关于无法将类型为“MS.Internal.NamedObject”的对象转换为自定义类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
过去是一个链接到我的博客的答案,但当我移动它的人downvote的答案。
ObservableCollection<MyCustomType>
that i bind to ComboBox
es, 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).
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. 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
}
}
Unable to cast object of type 'MS.Internal.NamedObject' to type 'MyNameSpace.MyCustomType'
I also set SelectedValuePath (you get the idea).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()
<custom:CComboBox x:Name="cmbFirstDko"
ItemsSource="{Binding Path=DataContext.MyFirstCollection, ElementName=myViewName}"
SelectedValue="{Binding anObjectID, Mode=TwoWay}"
SelectedValuePath="anObjectID">
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.