c# - WPF DataGrid how to get after adding a new row the values of the selected row - mvvm -


i know possibbly new duplicate, didn't find solution problem or maybe got logical disaster in brain... whatever, got datagrid bind datatable to. want add new row in datagrid/datatable. new row has inserted in sqlite db. i'am listening roweditending event newly values looks newly added row has first committed think - how can commit without stackoverflowexception , values?

wpf datagrid

                      <datagrid x:name="datagrid" horizontalalignment="stretch" verticalalignment="stretch"                               autogeneratecolumns="false"                                canuseraddrows="true" canusersortcolumns="false"                                scrollviewer.cancontentscroll="true" scrollviewer.verticalscrollbarvisibility="visible"                               itemssource="{binding path=mldb.tbl_technik}"                               selecteditem="{binding technicrow, mode=onewaytosource}"                               issynchronizedwithcurrentitem="true" >                         <i:interaction.triggers>                             <i:eventtrigger eventname="initializingnewitem">                                 <ic:callmethodaction methodname="teinitializingnewitem" targetobject="{binding}" />                             </i:eventtrigger>                             <i:eventtrigger eventname="roweditending">                                 <ic:callmethodaction methodname="teroweditending" targetobject="{binding}" />                             </i:eventtrigger>                             <i:eventtrigger eventname="selectionchanged">                                 <ic:callmethodaction methodname="teselectionchanged" targetobject="{binding}" />                             </i:eventtrigger>                         </i:interaction.triggers>                         <datagrid.columns>                             <datagridtextcolumn header="technik id" width="70" binding="{binding path=technikid}"/>                             <datagridtextcolumn header="techniktyp" width="100" binding="{binding path=techniktyp}"/>                             <datagridtextcolumn header="anlage" width="80" binding="{binding path=anlage}"/>                             <datagridtextcolumn header="anlagengruppe" width="100" binding="{binding path=anlagengruppe}"/>                             <datagridtextcolumn header="bemerkung" width="110" binding="{binding path=bemerkung}"/>                         </datagrid.columns>                     </datagrid> 

and parts of viewmodel looks this:

public void teinitializingnewitem(object sender, initializingnewitemeventargs e) { //raised if new row added   newrowte = true; }      public void teroweditending(object sender, datagridroweditendingeventargs e)     { //             selectedrow = e.row.getindex();          if (newrowte)         {              // position great values...         }         else         {             roweditendte = true;              datarowcollection drc = mldatasetcollection[0].tbl_technik.rows;             tbl_technikrow notupdatedrow = (tbl_technikrow)drc[selectedrow];             technicid = notupdatedrow.technikid;         }     }      public void teselectionchanged(object sender, selectionchangedeventargs e)     { //          if (roweditendte)         {             datagrid materialdg = (datagrid)sender;             materialdg.commitedit();              datarowcollection drc = mldatasetcollection[0].tbl_technik.rows;             tbl_technikrow updatedrow = (tbl_technikrow)drc[selectedrow];              updatetblte(updatedrow);              roweditendte = false;         }         else if (newrowte)         {             // here call function insert new row in sql db if rows changing (if user changed ui element or time down insert command)         }     } 

so there other event can listen to? or can tell me how values??

thanks #endregion


Comments

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -

minify - Minimizing css files -