Why does WPF have its own Color class instead of just using Drawing.Color?

Why does WPF have its own Color class instead of using Drawing.Color?

+4
source share
1 answer

I do not know for sure, but I suspect this for two reasons:

Firstly, Drawing.Color does not support automatic conversion to and from floating point for ARGB values ​​or color arithmetic, and both are needed for WPF. They could modify Drawing.Color to include it, but:

Secondly, Drawing.Color pollutes its namespace with static instances of itself for different common colors. WPF wisely moves this to a separate static class called Colors to store these instances.

I think this is probably so simple. In addition, Win.Forms and GDI + will (hopefully) one day be obsolete and trimmed. When this happens, problems will arise if there is a dependency on the old .DLL. Better just copy pasta and improve.

+5
source

All Articles