如何在DataGridComboBoxColumn ltems WPF添加背景颜色? [英] How add Background colors in DataGridComboBoxColumn ltems wpf?

查看:383
本文介绍了如何在DataGridComboBoxColumn ltems WPF添加背景颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试以这种方式,但它不工作。

 < D​​ataGridComboBoxColumn.ElementStyle> 

<样式和GT;
< setter属性=ComboBox.ItemsSourceVALUE ={绑定路径= ResourcesList}/>
< setter属性=ComboBox.ForegroundVALUE ={结合TypeOfEntry,转换器= {StaticResource的DisplayValueToBrushConverter}}/>
< setter属性=ComboBoxItem.BackgroundVALUE =嫩绿/>值=紫罗兰/>
< /样式和GT;


解决方案

如果你想设置组合框的背景颜色,而编辑DataGridComboBoxColumn,您可以使用此方法。

 < D​​ataGridComboBoxColumn> 
< D​​ataGridComboBoxColumn.EditingElementStyle>
<风格的TargetType =组合框>
< setter属性=背景值=白>< /二传手>
< /样式和GT;
< /DataGridComboBoxColumn.EditingElementStyle>
< / DataGridComboBoxColumn>



我想这和它工作正常。


i try in this way but its not working.

 <DataGridComboBoxColumn.ElementStyle>

                    <Style>
                        <Setter Property="ComboBox.ItemsSource" Value="{Binding Path=ResourcesList}" />
                        <Setter Property="ComboBox.Foreground" Value="{Binding TypeOfEntry, Converter={StaticResource DisplayValueToBrushConverter}}"/>
                         <Setter Property="ComboBoxItem.Background" Value="SpringGreen"/>Value="Violet"/>
                    </Style>

解决方案

If you want to set background color of ComboBox while editing DataGridComboBoxColumn, you can use this method

<DataGridComboBoxColumn>
    <DataGridComboBoxColumn.EditingElementStyle>
        <Style TargetType="ComboBox">
            <Setter Property="Background" Value="White"></Setter>
        </Style>
    </DataGridComboBoxColumn.EditingElementStyle>
</DataGridComboBoxColumn>

I tried this and it is working fine.

这篇关于如何在DataGridComboBoxColumn ltems WPF添加背景颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆