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

Disabled controls are too light

10 Answers 365 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
Jeff
Top achievements
Rank 1
Jeff asked on 01 Feb 2013, 09:23 PM
I'm getting complaints from the users that disabled controls on our data forms are too hard to read.

Is there some simple, global method for over-riding the foreground color selection used?

10 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 04 Feb 2013, 08:02 AM
Hello Jeffrey,

You can try editing the template of the data form and change the background of the border named "Background_Disabled". Let me know in case this does not lead you to the desired result.

Kind regards,
Maya
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Jeff
Top achievements
Rank 1
answered on 04 Feb 2013, 03:45 PM
Actually, we're already doing that. When we load the form, we set the background of every form with the name "Background_Disabled" to Brushes.Transparent.

The problem is that the foreground colors are too light.


0
Maya
Telerik team
answered on 05 Feb 2013, 02:03 PM
Hello Jeffrey,

The only thing we do when RadDataForm is disabled is to place a Border with different background once IsEnabled property is changed to "false". So, changing it should do the trick. Will it be possible to clarify which theme you are working with ?  

Greetings,
Maya
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Jeff
Top achievements
Rank 1
answered on 05 Feb 2013, 07:25 PM
The controls that are being displayed in the form are drawing with a lighter foreground color when the form is disabled than when it is not. This may be something that is happening within the individual controls, rather than in the form itself, but it's clearly happening.

"Will it be possible to clarify which theme you are working with ?"

All of them.  Or rather, our application allows the user to select which theme to use.

But all of the provided themes show this problem.
0
Maya
Telerik team
answered on 06 Feb 2013, 08:22 AM
Hi Jeffrey,

The theme with the lightest elements in disabled state is most probably Windows8Theme. I have tested the case and if the Background in disabled state is set to Transparent, all elements of the DataForm look ok. Still, all editing controls are in disabled state as well. Do you refer to them when saying the data form is not readable ? If that is the case, you will need to change their disabled states as well.  

Greetings,
Maya
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Jeff
Top achievements
Rank 1
answered on 06 Feb 2013, 07:57 PM
Yes, I am referring to the controls in the DataForm. If the form is disabled, then all of the controls are disabled, and the foreground color for each of the controls is too light.  Regardless of which theme is used.

Currently, I'm setting the Background_Disabled border to transparent with:
void myForm_Loaded(object sender, RoutedEventArgs e)
{
    foreach (Border border in this.ChildrenOfType<Border>())
    {
        if (border.Name == "Background_Disabled")
            border.Background = Brushes.Transparent;
    }
}
But I've been unable make this work in setting the foreground colors of the controls on the form.

This, for example:
foreach (FrameworkElement element in this.ChildrenOfType<FrameworkElement>())
{
    PropertyInfo foregroundProperty = element.GetType().GetProperty("Foreground");
    if (foregroundProperty != null)
        foregroundProperty.SetValue(element, Brushes.Red, null);
}
will successfully set the foreground color of every control on my form to red, when the form is opened in edit mode, but when the form is disabled, the labels stay red, but the foreground colors of all of the regular controls (textboxes, checkboxes, dropdowns, etc.) turn light gray.

0
Maya
Telerik team
answered on 07 Feb 2013, 08:04 AM
Hi Jeffrey,

I tested the case, but I was not able to reproduce the behavior where the editors do not get the Red foreground. I am attaching the project I used for the test. Is there something that I am missing ?  

Kind regards,
Maya
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Jeff
Top achievements
Rank 1
answered on 07 Feb 2013, 07:59 PM
I can see the foreground colors changing, in your example, as I wished they would in my code.

Two complexities in my code that I hadn't thought were relevant, but which seem to be:

  1. The fields in my forms have explicit content set, rather than the one that they would generate themselves by default.
  2. Rather than auto-generating the fields, the forms have templates set - and - those templates are from an external source, and are not part of the application.

In my app, the form templates are loaded from external files, and are constructed using XamlReader.Load(). But it doesn't look like it's the external loading that is the problem.

Starting with your example:

First: I created a DataTemplate that defined three DataFormDataFields, in Windows.Resources.
And I bound the form's ReadOnlyTemplate to that DataTemplate.
And the foreground colors changed as desired.

Second: I modified one the Name field in the template to use an explicit TextBox, instead of the auto-generated control.
And the foreground colors still changed as desired. Even in the explicit TextBox.

Third: I removed the form's ReadOnlyTemplate binding, and set ReadOnlyTemplate in MainWindow_Loaded()
And then, finally, I did not see the foreground color change, in the explicit TextBox.

The attachment mechanism in this forum will not allow .zip files, so I created a support ticket: 657307 to which I've attached a zip file containing this third example.


0
Accepted
Yordanka
Telerik team
answered on 08 Feb 2013, 03:26 PM
Hello Jeff,

Thank you for the project.

In your case, when the Foreground property is set the content of DataFormDataField is still not changed. Following code will resolve the problem:

private void officeBlackDataForm_Loaded(object sender, RoutedEventArgs e)
    {
      foreach (Border border in this.ChildrenOfType<Border>())
      {
        if (border.Name == "Background_Disabled")
          border.Background = Brushes.Transparent;
      }
   
      Dispatcher.BeginInvoke(new Action(() =>
      {
        foreach (FrameworkElement element in this.ChildrenOfType<FrameworkElement>())
        {
          PropertyInfo foregroundProperty = element.GetType().GetProperty("Foreground");
          if (foregroundProperty != null)
            foregroundProperty.SetValue(element, Brushes.Red, null);
        }
      }));
        
    }

 

Greetings,
Yordanka
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Jeff
Top achievements
Rank 1
answered on 08 Feb 2013, 04:26 PM
So, setting the foreground color works, it's just that I've been doing it too early.

Thanks for your help.
Tags
DataForm
Asked by
Jeff
Top achievements
Rank 1
Answers by
Maya
Telerik team
Jeff
Top achievements
Rank 1
Yordanka
Telerik team
Share this question
or