Set background color when disabled

5 posts, 0 answers
  1. Hans
    Hans avatar
    36 posts
    Member since:
    Nov 2017

    Posted 09 Jul Link to this post

    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

  2. Dimitar Dinev
    Admin
    Dimitar Dinev avatar
    64 posts

    Posted 09 Jul Link to this post

    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.
  3. Hans
    Hans avatar
    36 posts
    Member since:
    Nov 2017

    Posted 10 Jul in reply to Dimitar Dinev Link to this post

    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

  4. Hans
    Hans avatar
    36 posts
    Member since:
    Nov 2017

    Posted 11 Jul Link to this post

    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

  5. Dimitar Dinev
    Admin
    Dimitar Dinev avatar
    64 posts

    Posted 15 Jul Link to this post

    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.
Back to Top