0

I am trying to have to "skin" resource dictionaries for a wpf application that I would like to be able to switch between. I want to be able to set the background property of several user controls to a key that is a solidcolorbrush in one dictionary and null in the other.

How do I make a resource value that is null? The following doesn't seem to work.

<SolidColorBrush x:Key="ticketBodyBG">{x:Null}</SolidColorBrush>

Is there a way to do this, or should I just use a transparent brush key?

Kyeotic
  • 19,697
  • 10
  • 71
  • 128
  • Is there any problem with using ? – Jin-Wook Chung Oct 26 '11 at 16:32
  • No, I just wanted to know if setting it to null was a possibility. Since transparent black is roughly equivalent, its not a big deal. I just wanted to know. – Kyeotic Oct 26 '11 at 16:49
  • I see, but I think you need to catch the difference between null and transparent, which you may or may not know. Please refere to [{x:Null} vs. Transparent?](http://stackoverflow.com/questions/5344699/xnull-vs-transparent) – Jin-Wook Chung Oct 26 '11 at 17:03
  • That is actually what caused me to ask. – Kyeotic Oct 26 '11 at 17:39

2 Answers2

1

You can't set to null value, simply left the Brush empty, it will automatically will set to Transparent like this -

<SolidColorBrush x:Key="ticketBodyBG"></SolidColorBrush>
Dave Clemmer
  • 3,741
  • 12
  • 49
  • 72
Rohit Vats
  • 79,502
  • 12
  • 161
  • 185
0

Try:

<SolidColorBrush x:Key="ticketBodyBG" Color="#00000000"/>

It is equivalent to a null background (but is different from transparent i.e: the UIElement will not respond to hit testing)

Dave Clemmer
  • 3,741
  • 12
  • 49
  • 72
Louis Kottmann
  • 16,268
  • 4
  • 64
  • 88