c# - How can I restrict specific row of datagrid from being selected in WPF? -


i have datagrid in marking duplicate record in red color using datagrids loadingrow event.

xaml:

<datagrid x:name="datagrid"                    enablerowvirtualization="false"                    autogeneratecolumns="false"                    horizontalalignment="stretch"                    verticalscrollbarvisibility="auto"                    verticalalignment="bottom"                    canuseraddrows="false"                    width="auto"                    maxheight="216"                    loadingrow="datagrid_loadingrow">       <datagrid.columns>                 <datagridtextcolumn binding="{binding fullname, mode=oneway}" header="name"/>                 <datagridtextcolumn binding="{binding address.zip, mode=oneway}" header="plz"/>                 <datagridtextcolumn binding="{binding address.city, mode=oneway}" header="ort"/>       </datagrid.columns> </datagrid> 

code behind loading_row:

private void datagrid_loadingrow(object sender, datagridroweventargs e) {     try     {         tempobject temp = e.row.datacontext tempobject;          if (temp.isduplicate)         {             e.row.background = new solidcolorbrush((color)colorconverter.convertfromstring("#0066ff"));         }                          }     catch (exception ex)     {         throw ex;     } } 

solutions tried:

e.row.isenable = false; (datagrid_loadingrow) 

issue: works when try click on row, row did not selected. when select other valid row , press ctrl + a, rows got selected.

is there other way this? please provide answers sample code.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -