c# - WPF Bind datagrid column to child collection of the collection that is bound to the datagrid -


first want i'm pretty new wpf. i'm trying bind collection datagrid column child property of collection bind datagrid. collection bind datagrid:

public class commonuseparameterdata : observable { private string _currentname; public string currentname {         {         return _currentname;     }     set     {         if (_currentname == value) return;         _currentname = value;         raisepropertychanged("currentname");     } }  private string _currentvalue; public string currentvalue {         { return _currentvalue; }     set     {         if (_currentvalue == value) return;         _currentvalue = value;         raisepropertychanged("currentvalue");     } }  private commonuseparametertypevalue _currenttypevalue; public commonuseparametertypevalue currenttypevalue {         { return _currenttypevalue; }     set     {         if (_currenttypevalue == value) return;         _currenttypevalue = value;         raisepropertychanged("currenttypevalue");     } }  private observablecollection<commonuseparametertypevalue> _currenttypevalues; public observablecollection<commonuseparametertypevalue> currenttypevalues {     { return _currenttypevalues; }     set     {         if (_currenttypevalues == value) return;         _currenttypevalues = value;         raisepropertychanged("currenttypevalues");     } } } 

the collection want bind combobox in datagrid currenttypevalues. depending on comboboxcolumn (using datagridtemplatecolumn) selection different column (which combobox) should bound values. example parameter (which select in first comboboxcolumn) can value parsevalue , other column can have true , false values. every selection has own values. xaml:

<datagrid itemssource="{binding commonuseparameterdata}" autogeneratecolumns="false" canuseraddrows="true"> <datagrid.columns>     <datagridtemplatecolumn header="parametername" width="*">         <datagridtemplatecolumn.celltemplate>             <datatemplate>                 <combobox name="cbxparametertype" itemssource="{binding path=datacontext.commonuseparametertypes, relativesource={relativesource ancestortype={x:type usercontrol}}}" displaymemberpath="name" selecteditem="{binding currenttype}" selectedvaluepath="name" selectedvalue="{binding currentname}" iseditable="true" />             </datatemplate>         </datagridtemplatecolumn.celltemplate>     </datagridtemplatecolumn>                            <datagridtemplatecolumn header="parametervalue4" width="*">         <datagridtemplatecolumn.celltemplate>             <datatemplate>                 <combobox itemssource="{binding path=commonuseparameterdata.currenttypevalues }" iseditable="true" />             </datatemplate>         </datagridtemplatecolumn.celltemplate>     </datagridtemplatecolumn>        <datagridtemplatecolumn header="delete" width="auto">         <datagridtemplatecolumn.celltemplate>             <datatemplate>                 <button content="delete" command="delete"/>             </datatemplate>         </datagridtemplatecolumn.celltemplate>     </datagridtemplatecolumn> </datagrid.columns> 

i hope question clear , can me or tell me i'm trying possible/correct way?


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -