I have an issue using XamMultiColumnComboEditor v16.1 within a DataTemplate.
<DataTemplate DataType="{x:Type fields:HistoryClientInfoFieldViewModel}">
<ig:XamMultiColumnComboEditor ItemsSource="{Binding Values}" AutoGenerateColumns="False" SelectedValuePath="Name" DropDownButtonDisplayMode="Always" SelectedItemsResetButtonVisibility="Collapsed" Width="250"> <ig:XamMultiColumnComboEditor.Columns> <ig:TextComboColumn HeaderText="Name" Key="Name"/> <!--<ig:TextComboColumn HeaderText="OrderPlacer" Key="OrderPlacer"/>--> </ig:XamMultiColumnComboEditor.Columns> </ig:XamMultiColumnComboEditor> </DataTemplate>
First when setting the focus on the element there is an exception
exception thrown: 'System.InvalidOperationException' in PresentationCore.dll
Additional information: This Visual is not connected to a PresentationSource.
When attempting to set the value on the second time a null reference exception occurs.
Using the control inside a UserControl seems to work for some reason.
Any idea what is going wrong?
Thanks
Hi Etienne,
That's an interesting error. How are you using that DataTemplate? I see it has a DataType set which means it will automatically apply where HistoryClientInfoFieldViewModel is used but what parent control is expected to use this DataTemplate? For example, I tried creating a ListView control and used that DataTemplate for each list item but did not produce any exception when focusing via Mouse click or Tabbing to it. I tested using the last service release for 16.1 (16.1.20161.2231).
Also, do you have a stack trace for the error? I'm interested to see what method calls in the XamMultiColumnComboEditor are triggering the exception.
It is used in an items control containing other field model.So it is pretty much implicit datatamplte.The "expected parent" is simply a contentcontrol.
Oddly enough we dont get any stacktrace of the error.
I switched to a WrapPanel as the ItemsPanel but that didn't seem to change anything. Can you update the sample I attached in my last update to reproduce the exception and then send it back to me so I can debug it?
Trying to reproduce the issue.
Doesnt occur by simply putting the into a template.
So havnt found a way to reproduce it in a simple project.
The only thing new i found is that the exception only occur if I click on a an area with text. The adventure got a lot stranger.
So ill keep trying to repoduce it.
Found the issue but do not know a way around unless I handle DispatcherUnhandled exception. This is the stack trace .
at System.Windows.LogicalTreeHelper.GetParent(DependencyObject current) at Infragistics.DragDrop.DragDropManager.GetUIElementParent(DependencyObject element) at Infragistics.DragDrop.DragDropManager.OnMouseLeftButtonDown(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.OnMouseDownThunk(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.ContentElement.RaiseTrustedEvent(RoutedEventArgs args) 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 System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
So the element has a parent XamDataGridCell usign the DragDropManager. Not understanding why it i triggered but handling the exception seems the only workaround I can think of
While digging in the Infragistics DragDropManager source code I found mention of a bug fix that was made for a bug that had the exact same call stack as the one you listed. However, this bug fix was made way before 16.1 back in 2014. Are you positive that your application is using 16.1? What is the exact version # of the Infragistics DLLs that the application is referencing?
Basically if null is passed to the LogicalTreeHelper.GetParent() method it will throw an ArgumentNullException so we added a check to make sure that null is not passed in. This method will not, however, cause an InvalidOperationException. GetParent() just takes the passed in argument and tries to cast it to a FrameworkElement or FrameworkContentElement. http://www.dotnetframework.org/default.aspx/DotNET/DotNET/8@0/untmp/WIN_WINDOWS/lh_tools_devdiv_wpf/Windows/wcp/Framework/System/Windows/LogicalTreeHelper@cs/1/LogicalTreeHelper@cs (you'll have to search "GetParent" on this page to see the source code)
So I don't think an ArgumentNullException is possible if you are using the 16.1 DLLs since we added checks for that back in 2014. But first let's see what the exact version number is for the Infragistics DLLs you have referenced in your project.
I created a private support case for you to track the dev issue I logged. The case number is CAS-189707-R7S0Q4 and you can view it here: https://ko.infragistics.com/my-account/support-activity
I logged a dev issue for this so our engineers can make some changes around that code to account for null values getting passed to the GetParent() method. While I was not able to reproduce this locally the GetUIElementParent() method is very small and there are only two places where LogicalTreeHelper.GetParent() are called so I figured it would be ok to log this along with the call stack you provided. The dev issue ID is 247206.
For now, continue to use your workaround. I will open a private support case for you soon where I will link to this dev issue so you can track its status. Be aware that development has stopped for 16.2 and below so any fix that is made will be in 17.1 and above. Once the case is created I will update this thread and let you know.
We host elements in xamdatagrid styled as a list view.
Elements support drag and drop using drag drop manager. We use the drag drop manager to merge entries in the grid.
So at some point upon clicking an element on the grid inside the editor I've seen the drag drop procedure is activated on the MouseLeftButtonDown but unsuccessfully find a parent.
Hmm. I actually do see the possibility for an ArgumentNullException in the DragDropManager.GetUIElementParent method but I don't know how it could actually happen assuming the element that the DragSource is attached to is in the visual tree and I think it should be since the MouseLeftButtonDown event is firing which is what calls GetUIElementParent.
Speaking of the Infragistics DragDropManager, how are you using it in your app and how does it relate to the XamMultiColumnComboEditor? Based on the call stack it seems like an important part that my sample is missing so I'd like to try adding it in the same way it is used in your app.
version used is 16.1.20161.1000.