What is the difference between System.Drawing.Color and System.Windows.Media.Color?

Basically, why do we need two abstractions of a fairly simple concept?

+24
Mar 11 '10 at 21:45
source share
2 answers

System.Windows.Media.Color is part of the System.Windows.Media space:

Provides types that integrate multimedia materials, including drawings, text, and audio / video content into Windows Presentation Foundation (WPF) applications.

System.Drawing.Color is part of the System.Drawing space:

The System.Drawing namespace provides access to the GDI + functionality of the underlying graphics. More advanced features are provided in the System.Drawing.Drawing2D, System.Drawing.Imaging, and System.Drawing.Text namespaces.

I assume the latter applies to Windows, while the former is more general and more easily portable for Mac OS, etc. for use in Silverlight applications.

There is also this caution in the last namespace that will support this:

Classes in the System.Drawing namespace are not supported for use in a Windows service or ASP.NET. Attempting to use these classes from one of these application types can cause unforeseen problems, such as degraded service performance and runtime exceptions.

+14
Mar 11 '10 at 21:52
source share

I don’t think there is a β€œneed” as such, they just made an early (possibly wrong) decision to put the Color class in WinForms-specific System.Drawing - because at that time Win32 and Winforms were all there was.

Later, when they wanted to improve concepts in Color, they did not want WPF to depend on WinForms. Therefore, instead of correcting the situation by moving the more abstract Color class to the general assembly, they simply copied the new Color class to WPF.

+8
Jun 23 '13 at 22:03
source share



All Articles