System.Nullable<Color> Property DataTemplate

Jan 10, 2011 at 3:17 PM
Edited Jan 10, 2011 at 3:30 PM

I have a property type System.Nullable<Color> and it's not getting the Color Picker DataTemplate.

Looking at the definition for the DataTemplate in ExtendedEditors.xaml, it's not clear to me how to fix this.

Any advice?

 

Thanks,

Bill

Coordinator
Jan 12, 2011 at 7:38 AM

Hi Bill, I also fixed this bug, now you should get the color picker also for you Nullable<Color>. 

I don't know why it is showing "Yellow 31%" when the value is Null - will have a look at that later. That's a problem in the ColorPicker class, I guess.

Developer
Jan 12, 2011 at 7:32 PM

The "Yellow 31%" is the default value for the SelectedColorProperty in the colorpicker class. I think it is a good default value since it clearly shows that you haven't bound the property to anything yet :)

Coordinator
Jan 13, 2011 at 7:19 AM

Right, I should have known that :)

I am thinking to replace this with an "Undefined" Color value (e.g. #00000000) - and show "Undefined" in the text when this is selected.

We could also provide an "Automatic" (e.g. #00000001) value as in Word...

Developer
Jan 13, 2011 at 8:00 PM

#00000000 is Transparent, isn't it?

Why not leave it as-is, or use Black as the default color. I say it is up to the the application programmer to decide the default value for his own properties.

Coordinator
Jan 14, 2011 at 6:57 AM

Transparent is #00FFFFFF, that's why I think an "Undefined" color could be #00000000 (Null of type Color? could also be marked as undefined).

Developer
Jan 14, 2011 at 5:02 PM

Ah, yes.

However, if the user temporarily wants to set a color property which is currently black to completely transparent by dragging the slider, it'll look pretty weird that it is then named as "Undefined", from a user point of view. Why not drop the "Undefined"-concept all together? Do we actually need it?