相关疑难解决方法(0)

如何通过在WPF中绑定来设置复选框内容的背景颜色

我试图弄清楚如何绑定内容的背景颜色为复选框.这是我的代码,当然背景设置只是改变复选框的颜色而不是文本背后的颜色.

        <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>
Run Code Online (Sandbox Code Playgroud)

wpf checkbox styling

4
推荐指数
1
解决办法
7935
查看次数

标签 统计

checkbox ×1

styling ×1

wpf ×1