In one of my WPF projects, I have a UserControl as following:
<UserControl x:Class="Repository.UI.SetupModule.CalcRate.UserControl1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:ig="http://schemas.infragistics.com/xaml" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="300">
<Grid> <ig:XamComboEditor/> </Grid></UserControl>
I got the error on the XamComboEditor : Object reference not set to an instance of an object.
The StackTrace is:
at Infragistics.Controls.Editors.ComboEditorBase`2.OnApplyTemplate() at System.Windows.FrameworkElement.ApplyTemplate()
For testing purpose, I create a brand new WPF project, and add the same UserControl to the project, this time, there's no error on the XamCombeEditor.
I guess there must something in my project that causes the error, but unable to find out what it is.
please help, thanks.
Hi yingwu,
What is the version # on the Infragistics DLLs that you are using? I took a look in the latest source code available and inside ComboEditorBase.OnApplyTemplate(), every object being used has a null check around it so I can't see how you would be getting that exception. If I know what exact version you are using I can check that specific source code to see if there is anything different.
Hi Rob,
the version # for the InfragisticsWPF4.Controls.Editiors.XamComboEditor.v14.2.dll is 14.2.20142.1000.
Also, I have searched the whole solution for a style that might be targeting the ig:XamComboEditor, but found none. However, we do have a named style that targets the igWpf:XamComboEditor, not sure this has anything to do with the error.
Thank you very much for your help.
It depends on what the namespace igWpf is set to in the xaml. At the top of the xaml file that has igWpf in it, what is the value for xmlns:igWpf=?
I went over the source code for 14.2.20142.1000 and most of the code inside OnApplyTemplate is the same. One thing I overlooked the first time I checked the source code was a piece of code that was looking for a popup resizer:
this._resizer = this._rootPopupParent.FindName("Resizer") as PopupResizer;this._resizer.PopupResizing += Resizer_PopupResizing; this._resizer.PopupResized += Resizer_PopupResized;
There is no null check around the PopupResizing events so maybe this is where it's causing the exception for you? In the default styles for the XamComboEditor template I can see the resizer control that it's looking for so as long as you haven't changed that, it should find it.
here are the namespace for Infragistics in the xaml of my project:
xmlns:ig="http://schemas.infragistics.com/xaml" xmlns:igEditors="http://infragistics.com/Editors" xmlns:igWpf="http://schemas.infragistics.com/xaml/wpf" xmlns:igDP="http://infragistics.com/DataPresenter" xmlns:igWindows="http://infragistics.com/Windows"
Thanks.
Let me know if you have any further questions on this matter.
Thank you Rob.
Ok. With that namespace, igWpf:XamComboEditor will be the WPF only comboeditor. ig:XamComboEditor will be the Silverlight/WPF combo editor. Also your stack trace for the error points to the ig:XamComboEditor so we know it's not the WPF only version. I would say that your igWpf:XamComboEditor style probably doesn't have anything to do with it.
At this point I'd recommend downloading the source code from your account, building it (there is a batch file you can run for easy building), and then referencing those newly built DLLs in your project instead of the installed ones. Then reproduce the error. It should break inside the source code on the exact line where it's crashing. My best guess is that it cannot find that popup resizer but that should only occur if 1.) it couldn't find the default template for the editor, or 2.) you overlooked a style in the project that is changing the ig:XamComboEditor template. Without having a sample on my end that reproduces the issue I can't say for sure what the cause is. At least with the source code you will be able to see exactly why line it crashes on and we can then see what component it's trying to access.