c# - ComboBox of colored TextBlock WPF -
c# - ComboBox of colored TextBlock WPF -
i'm trying create datagrid each cell combobox, each combobox lists colors list, , selected value default read database.
my problem couldn't color background of each item in combobox according colors list
<datagrid.columns> <datagridtemplatecolumn x:name="comboboxcolumntemplate"> <datagridtemplatecolumn.celltemplate> <datatemplate> <combobox itemssource = "{binding colorslist}" > <combobox.itemtemplate> <datatemplate> <textblock text="" background="{binding ???}" /> </datatemplate> </combobox.itemtemplate> </combobox> </datatemplate> </datagridtemplatecolumn.celltemplate> </datagridtemplatecolumn> </datagrid.columns> how can accomplish this?
update >>>
i tried suggested solution sheridan
, works me, when select item background of combobox doesn't take background of selected item. need because utilize combobox color selection.
thank you.
it depends on within colorslist... if collection of solidcolorbrushes, this:
<combobox itemssource="{binding colours}"> <combobox.itemtemplate> <datatemplate> <textblock text="put text in here" /> </datatemplate> </combobox.itemtemplate> <combobox.itemcontainerstyle> <style> <setter property="combobox.background" value="{binding}" /> </style> </combobox.itemcontainerstyle> </combobox> however, if collection of type color, won't work because textblock.background of type brush.
update >>>
i've updated code illustration utilize itemcontainerstyle instead because color whole background of comboboxitem, rather textblock.
c# wpf datagrid
Comments
Post a Comment