This is a migrated thread and some comments may be shown as answers.

Set background color when disabled

4 Answers 3733 Views
MultiColumnComboBox
This is a migrated thread and some comments may be shown as answers.
Hans
Top achievements
Rank 1
Veteran
Hans asked on 09 Jul 2019, 11:26 AM

Hi, 

I'm trying to set the background color for a disabled MultiColumnComboBox using a style, without succes.  Here's my code

<Style x:Key="DefaultTelerikRadMultiColumnComboBoxStyle" TargetType="telerik:RadMultiColumnComboBox" BasedOn="{StaticResource RadMultiColumnComboBoxStyle}">
    <Setter Property="FontFamily" Value="{StaticResource DefaultFont}"/>
    <Setter Property="FontSize" Value="{StaticResource DefaultFontSize}"/>
    <Setter Property="FontWeight" Value="{StaticResource DefaultFontWeight}"/>
    <Setter Property="MinHeight" Value="{StaticResource DefaultMinimumHeight}"/>
    <Setter Property="KeepDropDownOpen" Value="False"/>
    <Setter Property="CloseDropDownAfterSelectionInput" Value="True"/>
    <Setter Property="SelectionBoxesVisibility" Value="Visible"/>
 
    <Setter Property="Validation.ErrorTemplate" Value="{StaticResource ErrorTemplate}"/>
 
    <Style.Triggers>
        <Trigger Property="IsEnabled" Value="True">
            <Setter Property="Background" Value="{StaticResource DefaultTextBoxBackgroundColor}"/>
        </Trigger>
        <Trigger Property="IsEnabled" Value="False">
            <Setter Property="Background" Value="WhiteSmoke"/>
        </Trigger>
        <Trigger Property="IsFocused"  Value="True">
            <Setter Property="Background"  Value="{StaticResource DefaultTextBoxIsFocusedBackgroundColor}"/>
        </Trigger>
    </Style.Triggers>
</Style>
<Style TargetType="{x:Type telerik:RadMultiColumnComboBox}" BasedOn="{StaticResource DefaultTelerikRadMultiColumnComboBoxStyle}"/>

 

Any ideas ?

Regards
Hans

4 Answers, 1 is accepted

Sort by
0
Dimitar Dinev
Telerik team
answered on 09 Jul 2019, 01:59 PM
Hi Hans,

Thank you for the code snippet.

I made a sample project in which I used a similar approach, however on my end the Background is applied as intended.

Attached, you can find the sample project. Please, review it and let me know if you find it helpful.

Should you need any further assistance, may I ask you to modify the sample project in order to demonstrate the observed on your end result and send it back? Note, that you can open a new support ticket in order to attach the project. This way I will be able to investigate the scenario and better assist you. 

I am looking forward to your reply.

Regards,
Dimitar Dinev
Progress TelerikWant to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Hans
Top achievements
Rank 1
Veteran
answered on 10 Jul 2019, 03:22 PM

Hi Dimitar,

thanks for the replay and the sample project, which as you stated works just fine. I'm trying to determine why it doesn't work in my project.  I'll get back to you as soon as I find out.

Regards,
Hans

0
Hans
Top achievements
Rank 1
Veteran
answered on 11 Jul 2019, 11:43 AM

Hi Dimitar

I copied your control and style to one of my test forms and have the same problem.  But here's the thing: the trigger does not work only for IsEnabled = false.  Setting the vlalue to true gives me the right background color.  Any ideas why this is the case ?

As for your sample project, how come there is a diffrence between the color shown in the control and the one shown in the properties window as you can see in the attached file ?

Regards,
Hans

0
Dimitar Dinev
Telerik team
answered on 15 Jul 2019, 11:20 AM
Hi Hans,

Thank you for the description and screenshot.

I was only able to reproduce the described behavior by setting the Background property directly to the control. Because a local value has a higher priority, the Style Trigger is ignored. Could you check if somewhere in the project the Background is set either in the XAML or in code-behind? If not, please send me a project that shows the behavior, so I can investigate further.

In the sample project, the reason why there is a difference between the shown color and the one in the properties window is because when the RadMultiColumnComboBox is disabled, the SearchAutoComplete's opacity is set to 0.6. By editing the control template for RadMultiColumnComboBox, the opacity can be reset or modified in the trigger for the control's disabled state:

<Trigger Property="IsEnabled" Value="False">
        <Setter Property="Background" TargetName="PART_SearchAutoCompleteBox" Value="Lime"/>
        <Setter Property="Opacity" TargetName="PART_SearchAutoCompleteBox" Value="1"/>
</Trigger>

Attached, you can find the updated sample project in which I've demonstrated this approach.

Regards,
Dimitar Dinev
Progress TelerikWant to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
MultiColumnComboBox
Asked by
Hans
Top achievements
Rank 1
Veteran
Answers by
Dimitar Dinev
Telerik team
Hans
Top achievements
Rank 1
Veteran
Share this question
or