0

I wanted to change the disabled background of my Textbox to a semitransparent Gradientbrush (one part transparent the other not).
I found this older post to a almost identical topic: this one
The accepted answer worked for my, as long as I did not wanted to add any transparency to it. Instead the transparent part of the background turns to some shade of gray.

How can I fix this a nice and clean way, the Template form the MS-Page might do the trick, but they always look so awfully giant for such small issues.

Community
  • 1
  • 1
lsteinme
  • 750
  • 1
  • 6
  • 20

1 Answers1

0

I have done something similar to a different control. I added my owncallback to the IsEnabled property like this

static IconPresenter()
  {
     IconPresenter.IsEnabledProperty.OverrideMetadata(typeof(IconPresenter), new UIPropertyMetadata(new PropertyChangedCallback(OnIsEnabledChanged)));
  }

And then I added in the code that I wanted to happen when the IsEnabled is changed

private static void OnIsEnabledChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
  {
     IconPresenter iconPresenter = (IconPresenter)sender;

     if ((bool)e.NewValue == false)
     {
        iconPresenter.Fill = Brushes.Transparent;
     }
     else
     {
        iconPresenter.Fill = Brushes.Black;          
     }
  }
Ralt
  • 2,084
  • 1
  • 26
  • 38