wpfdatagrid - Subclass binding in wpf to datagrid column -
i have class of following details:
public class contact public prime contactprime end class public class contactprime property conid string property conname string property company string property jobtitle string property contactno string property addr string property type string end class
i have datagrid , item source set contactlist(of contact), question how can display prime.conname.
additional info: following current databinding in datagrid:
<datagrid autogeneratecolumns="false" name="datagrid1" margin="0,10,0,0" height="500" width="695" horizontalscrollbarvisibility="auto" verticalscrollbarvisibility="visible" selectionmode="single" isreadonly="true" > <datagrid.columns> <datagridtextcolumn binding="{binding conname}" header="name" width="150" /> <datagridtextcolumn binding="{binding contactno}" header="numbers" width="150"/> <datagridtextcolumn binding="{binding addr}" header="address" width="150"/> <datagridtextcolumn binding="{binding type}" header="type" width="80"/> <datagridtextcolumn binding="{binding company}" header="company" width="70" /> <datagridtextcolumn binding="{binding jobtitle}" header="job" width="70"/> </datagrid.columns> </datagrid>
you can bind properties, not fields, ensure prime
property of contact
.
also, if wish ui notified of changes, should implement inotifypropertychanged on types.
if wish ui notified of collection changes contact list, should implement inotifycollectionchanged. observablecollection type provided wpf this.
Comments
Post a Comment