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

Disable background color 'dim' for readonly

5 Answers 723 Views
MaskedInput (Numeric, DateTime, Text, Currency)
This is a migrated thread and some comments may be shown as answers.
Chad
Top achievements
Rank 1
Chad asked on 13 Jan 2017, 06:34 AM
An input control will 'dim' it's background color when IsReadOnly is set to true. This, unfortunately, have the undesired side effect of turning some lighter colors gray. Is there a means of setting the 'read-only' background color without it being altered by the control when the control is read only?

5 Answers, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 17 Jan 2017, 12:54 PM
Hello Chad,

If we have understood you correctly, you want to change the background color of the mask when the IsReadOnly property is set to true. If this is the case, you can extract and edit the default template of the control. In the extracted template, you can navigate to a VisualState with and set your custom color. If we are in the wrong direction you can elaborate more on what exactly you are trying to achieve in your application. You can send us pictures with the desired result. This way we can better understand your approach.

Regards,
Dinko
Telerik by Progress
Want 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
Chad
Top achievements
Rank 1
answered on 19 Jan 2017, 03:03 AM

Hi & thanks Dinko,

That's it, now I just wish there was a global/theme way of altering that brush color for all the controls at once.

Regards,
Chad

0
Dinko | Tech Support Engineer
Telerik team
answered on 23 Jan 2017, 11:56 AM
Hi Chad,

Currently, only the Office2016 and Green themes provide a property which you can use to change the global ReadOnly background color for all controls.
public MainWindow()
{
    InitializeComponent();
    Office2016Palette.Palette.ReadOnlyBackgroundColor = Color.FromRgb(255,0,0);
        // or
    GreenPalette.Palette.ReadOnlyBackgroundColor = Color.FromRgb(255, 0, 0);
}

Regards,
Dinko
Telerik by Progress
Want 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 you to write beautiful native mobile apps using a single shared C# codebase.
0
Константин
Top achievements
Rank 1
answered on 18 May 2017, 02:31 PM

Hello!

How can I change the color of background by styleTrigger? I have some boolean properties In ViewModel of DataContext, depends on color of Background.  LIke

<Style x:key="Style1" BasedOn="{StaticResource RadMaskedInputStyle}" TargetType="RadMaskedInput" >

<Style.Triggers>

<DataTrigger Binding="{Biding IsBranchReject}" Value="True">

<Setter Property="Background" Value="Pink"/>

///

What Property i need to use in order to change color of background of ReadOnly control?

0
Dinko | Tech Support Engineer
Telerik team
answered on 23 May 2017, 11:57 AM
Hello Константин,

An approach which you could try is to extract the default template of the control. In the extracted style you can remove VisualState with x:Name="ReadOnly". Then you can create a style based on the extracted one where you can set the DataTrigger and depending on the property to set the Background property of the control.

For your convenience, we have created sample project which demonstrates the approach mentioned above. Give this project a try and let us know if it works for you.

Regards,
Dinko
Telerik by Progress
Want 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 you to write beautiful native mobile apps using a single shared C# codebase.
Tags
MaskedInput (Numeric, DateTime, Text, Currency)
Asked by
Chad
Top achievements
Rank 1
Answers by
Dinko | Tech Support Engineer
Telerik team
Chad
Top achievements
Rank 1
Константин
Top achievements
Rank 1
Share this question
or