wpf - Programmatically enter edit mode on datagrid row -


i have following request: items added , removed datagrid (wpf) button click. when user adds new row (new item) in datagrid, want automatically enter edit mode on new item. work if selectionunit cell, fullrow. tried change selectionunit cell before calling datagrig.beginedit() doesn't work.

here's code:

<datagrid name="dgdatagrid"  margin="20,20,3,3" canusersortcolumns="true" itemssource="{binding allitems}"     autogeneratecolumns="false" selectionunit="fullrow"  selectionmode="single" canuseraddrows="false" canuserdeleterows="false"     canuserresizerows="true" canuserreordercolumns="false">     <datagrid.columns>         <datagridtextcolumn header="first column name" minwidth="160" binding="{binding path=firstcolumn}"/>         <datagridcheckboxcolumn header="second column name" minwidth="100" binding="{binding path=secondcolumn, updatesourcetrigger=propertychanged}"/>     </datagrid.columns> </datagrid> 

and background functionality:

private void addnewitem() {     var newitem = new item();     allitems.add(newitem);     dgdatagrid.scrollintoview(newitem );     dgdatagrid.selecteditem = newitem ;     var selectedindex = dgdatagrid.selectedindex;      dgdatagrid.selectionunit = datagridselectionunit.cell;     dgdatagrid.currentcell = new datagridcellinfo(dgdatagrid.items[selectedindex], dgdatagrid.columns[0]);     dgdatagrid.beginedit();     dgdatagrid.selectionunit = datagridselectionunit.fullrow; } 


Comments

Popular posts from this blog

java - Cast from Object to List<String>: CastClassException -

How to set a border for android Imageview in Longpress? -

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -