开发者

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

开发者 https://www.devze.com 2023-01-10 09:39 出处:网络
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:

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消