我试图弄清楚如何为复选框绑定内容的背景色。这是我的代码,当然,背景设置只会更改复选框的颜色,而不是文本后面的颜色。
<ListBox Name="ListBox1" ItemsSource="{Binding Path=relationshipTypesTable.dataTable.DefaultView}">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<CheckBox IsChecked="True" Content="{Binding typeDesc}" Background="{Binding color}"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
尝试这个:
<ListBox Name="ListBox1" ItemsSource="{Binding Path=relationshipTypesTable.dataTable.DefaultView}">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<CheckBox IsChecked="True">
<TextBlock Text="{Binding typeDesc}" Background="{Binding color}"/>
</CheckBox>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句