WPF DataGrid cannot Add a row when datasource is empty -


canuseraddrows="true" 'works' when there's data in itemssource of datagrid. if happens there no rows in original list of items, datagrid doesn't display placeholder row entering new items, though i've set canuseraddrows="true". why?!

thanks in advance, trindaz

this seem known issue wpf datagrid. see discussion here (starting 4th comment) seem fixed in .net 4. i've made tests issue on 3.5 , 4 (beta2) frameworks. pls, see results below:

first defined 3 types of item collections:

public class testgriditems0 : arraylist { }  public class testgriditems1 : list<testgriditem> { }  public class testgriditems2<t> : list<testgriditem> { } 

where testgriditem below:

public class testgriditem {     public string 1 { get; set; }     public string 2 { get; set; }     public string 3 { get; set; } } 

.net 3.5

testgriditems0 , testgriditems1 didn't show empty line empty collection; testgriditems2 did work fine.

.net 4

only testgriditems0 didn't show line empty collection; other 2 worked fine.

xaml grid:

<my:datagrid name="datagrid" autogeneratecolumns="false" canuseraddrows="true">     <my:datagrid.columns>         <my:datagridtextcolumn binding="{binding one}" header="one" />         <my:datagridtextcolumn binding="{binding two}" header="two" />         <my:datagridtextcolumn binding="{binding three}" header="three" />     </my:datagrid.columns> </my:datagrid> 

below how items source assigned:

datagrid.itemssource = new testgriditems0(); datagrid.itemssource = new testgriditems1(); datagrid.itemssource = new testgriditems2<testgriditem>(); 

hope helps, regards


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -