【发布时间】:2012-12-28 01:44:43
【问题描述】:
我有一个 ComboBox,绑定到一个对象列表。我可以让对象很好地填充下拉列表。我正在尝试为下拉项目列表中的每个对象设置背景颜色。我可以在下面的样式代码中轻松地为它们设置任何颜色。
我要做的是将背景颜色值绑定到我的 Key 对象的 KeyColorValue 字段。
这是我的 XAML:
DisplayMemberPath="Name"
HorizontalAlignment="Left"
Margin="300,103,0,0"
VerticalAlignment="Top"
Width="186"
SelectionChanged="roleBoundSelector_SelectionChanged" >
<ComboBox.ItemContainerStyle>
<Style TargetType="ComboBoxItem">
<Setter Property="Background"
Value = "{Binding Path=KeyColorValue}" />
(如果我在这里输入颜色,它就可以正常工作...需要绑定到 MyKeys 对象的 KeyColorValue。)
【问题讨论】:
标签: xaml data-binding combobox setter