c# - WPF DataGridComboBoxColumn not showing initial binding value -
i succesfully binding collection datagrid , succesfully binding property datagridcomboboxcolumn. (there wpf tool called snoop allows me investigate if data has been bound).
but reason initial data not being shown. after change selection manually. value visibly available.
any tips or appreciated !
thank you,
here xaml:
<datagridcomboboxcolumn width="*" displaymemberpath="redoms" header="myheader" itemssource="{binding source={staticresource mymodel}, path=srcollection, mode=oneway}" selectedvaluebinding="{binding azsr, mode=twoway}" selectedvaluepath="id"> <datagridcomboboxcolumn.cellstyle> <style basedon="{staticresource edgridcell}" targettype="datagridcell"> <setter property="isenabled" value="false" /> <style.triggers> <datatrigger binding="{binding azbev, mode=oneway}" value="false"> <setter property="background" value="{staticresource klrcolor}" /> <setter property="isenabled" value="true" /> </datatrigger> </style.triggers> </style> </datagridcomboboxcolumn.cellstyle> <datagridcomboboxcolumn.editingelementstyle> <style targettype="combobox"> <setter property="background" value="{staticresource klrcolor}" /> </style> </datagridcomboboxcolumn.editingelementstyle> </datagridcomboboxcolumn>
here static resource edgridcell
<style x:key="edgridcell" targettype="{x:type datagridcell}"> <eventsetter event="uielement.previewmouseleftbuttondown" handler="datagridcell_previewmouseleftbuttondown" /> <style.triggers> <trigger property="isselected" value="true"> <setter property="background" value="yellow" /> <setter property="foreground" value="black" /> </trigger> </style.triggers> </style>
override equals because it's item isn't same actual instance 1 in items collection, binding doesn't work. snoop show same values, may think same, when isn't. put in class defining object, replacing myclasswith class type etc.
public override bool equals(object obj) { if (obj == null || !(obj myclass)) return false; return ((myclass)obj).id == this.id); }
more info: https://rachel53461.wordpress.com/2011/08/20/comboboxs-selecteditem-not-displaying/#comments
Comments
Post a Comment