Why does WPF have its own Color class instead of just using Drawing.Color?
Why does WPF have its own开发者_高级运维 Color class instead of just using Drawing.Color?
I don't know for certain, but I suspect it is for two reasons:
First, Drawing.Color
does not support automatic conversion to and from floating point for ARGB values or color arithmetic, and both were necessary for WPF. They could have modified Drawing.Color
to include it, but:
Second, Drawing.Color
pollutes its namespace with static instances of itself for the various common colors. WPF wisely moves this to a separate static class called Colors
to hold these instances.
I think it's likely as simple as that. Besides, Win.Forms and GDI+ will (hopefully) one day be deprecated and pruned. When that happens, there will be trouble if there's a dependency on the old .DLL. Better to just copy-pasta and enhance.
精彩评论