We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Adding Columns during runtime lead to an exception error

Thread ID:





143265 Mar 12,2019 09:07 AM UTC Mar 13,2019 01:22 PM UTC WPF 1
Tags: SfDataGrid
Victor Dienstbier
Asked On March 12, 2019 09:07 AM UTC

Hi everybody,

I really need you help! I developted a program in C# with WPF.

I have a MainWindows with a frame in it, loading a Page. In this page I used a SfDataGrid. During the runtime I cahnge Visibility of the Frame-Element and remove all columns from the SfDataGrid (Columns Binding to a collection). Since some users complained about problems with filtering and sorting I decided to update the SfDataGrid to the newest Version (16.4460.0.42). Since the update following occurs everytime: When I change the Fram's Visibility to visible for the first time everything works perfectly. But when I change the Frame'sVisibility to Collapsed and then to Visible again and Add Columns to the SfDataGrid the program crashed and tells me:

System.NullReferenceException: "Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt."

There are no further information for this error...

This is basically what I do:

public void CreateColumns()
                //this.Dispatcher.BeginInvoke((Action)delegate ()


                AddColumns(); //By leaving this line, where I add Columns to the Collection, there is no error, but of course no columns are being added!!!

            catch (Exception e)


private void AddColumns()
            foreach (Syncfusion.UI.Xaml.Grid.GridColumn column in Columns_Arbeitsvorrat)
                //dtgArbeitsvorrat.Columns.Add(column); //Even if I do not bind the columns to the grid the error occures

This is the DataGrid:
<syncfusion:SfDataGrid Name="dtgArbeitsvorrat"
                                           ItemsSource="{Binding ElementName=dpArbeitsvorratPager, Path=PagedSource}"
                                           SelectedItem="{Binding ElementName=_pagFormularINR, Path=selectedINRFormular}"
                                           Columns="{Binding ElementName=_pagFormularINR, Path=columnCollection}"
                                           SelectionMode="{local:SettingBinding Path=bSettingsMultiSelectionInDataGrid, Converter={StaticResource boolToSelectionModeConverter}}"
                                           GridCopyOption="CopyData, IncludeHeaders"
                                           FilterChanged="dtgArbeitsvorrat_FilterChanged" KeyUp="dtgArbeitsvorrat_KeyUp" 

                                <MenuItem Name="miArbeitsvorrat_CopyListToClipboard" Header="{x:Static p:Resources.Copy}" Click="MenuItem_Click">
                                        <Image Source="/Icons/Copy32x32.png" />

Please tell me if you need more information!

Can you tell me what I'm doing wrong? Or changed anything in the SfDataGrid?

Thank you very much!!!


Shobika Palani [Syncfusion]
Replied On March 13, 2019 01:22 PM UTC

Hi Victor, 

Thank you contacting Syncfusion Support. 

We have prepared sample based on the provided details. But we are unable to reproduce the reported issue in the mentioned version Please find the tested sample from our end in the below link 

Sample Link: 

If still issue is reproduced at your end, please revert us with the modified sample. It will help us to investigate exact cause for the issue and provide better solution at the earliest. 



This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon