c# - DataGrid row datatrigger/template -


i have following datagrid:

<datagrid itemssource="{binding coll.view}" selecteditem="{binding selectedtransaction}"           scrollviewer.cancontentscroll="true"            scrollviewer.verticalscrollbarvisibility="visible"           autogeneratecolumns="false">      <datagrid.columns>         <datagridtextcolumn header="date" binding="{binding date}" width="100" />         <datagridtextcolumn header="category" binding="{binding path=selectedcategory.categoryname}" width="100" />         <datagridtextcolumn header="payee" binding="{binding path=selectedpayee.payeename}" width="100" />         <datagridtextcolumn header="withdrawal"  width="100" />         <datagridtextcolumn header="deposit"  width="100" />         <datagridtextcolumn header="total" binding="{binding accountbalance}" width="100" />     </datagrid.columns> 

transactions observablecollection of transactionviewmodel items.

the items have property enum can either : deposit, withdrawal.

private transactiontypes ttype; public transactiontypes transactiontype {     { return ttype; }     set     {         ttype = value;         onpropertychanged("transactiontype");     } } 

and 1 :

public double? transactionammount {     { return ammount; }     set     {         ammount = value;         onpropertychanged("transactionammount");     } } 

is possible bind transactionammount based on value of transactiontype? if transactiontype deposit bind transactionammount deposit datagrid column.

if transactiontype withdrawal bind the transactionammount withdrawal column.

you have use elementstyle , edittingelementstyle achieve want in combination triggers :

<datagridcheckboxcolumn header="ok" binding="{binding goedgekeurd,updatesourcetrigger=propertychanged}"                                     elementstyle="{staticresource goedkeuringcheckboxstyle}"                                     editingelementstyle="{staticresource goedkeuringcheckboxstyle}"/> 

the styles defined upfront in resources :

<style x:key="goedkeuringcheckboxstyle" targettype="checkbox">         <setter property="horizontalalignment" value="center" />         <setter property="verticalalignment" value="center" />         <style.triggers>             <datatrigger binding="{binding iswachtopgoedkeuringklant}" value="false">                 <setter property="isenabled" value="false"/>             </datatrigger>         </style.triggers>     </style> 

the examples here taken code did not change them fit question hope can follow happening , adjust needs. point binding on row level.

but if use mvvm can logic in viewmodel , not in view. make things more simple.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -