c# - ItemSource in DataGrid Error: Exception has been thrown by the target of an invocation -



when call headersdatagrid.itemssource application throws exception. can please me debug , determine error is? thanks

code

public static list<item> getheaders()     {         item i1 = new item();         i1.label = "tst";         i1.description = "this header testing";         item i2 = new item();         i2.label = "ts2";         i2.description = "this second header , used testing purposes :)";         item i3 = new item();         i3.label = "ts3";         i3.description = "this third header , used testing purposes :d";         list<item> headers = new list<item>();         headers.add(i1);         headers.add(i2);         headers.add(i3);         return headers;     }        public mainwindow()     {         displayheaders();         initializecomponent();     }      /// <summary>     /// purpose of method display of headers     /// </summary>     public void displayheaders()     {         //list<item> headers = database.getheaders();          // testing purposes         list<item> headers = testingclass.getheaders();          // handle headers         headersdatagrid.itemssource = headers;               } 

xml

            <grid name="grid_headers" background="honeydew">                 <datagrid x:name="headersdatagrid" autogeneratecolumns="true"></datagrid>             </grid> 

the error indicates headersdatagrid null. try moving displayheaders method post initialize component call.


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -