ExtensionMethod.NET Home of 820 C#, Visual Basic, F# and Javascript extension methods

ToFormsColor

Converts a System.Windows.Media.Color (WPF) into System.Drawing.Color (WinForms) In mixed projects using Windows-Forms and WPF, there is sometimes the need to convert colors between both.

Source

<System.Runtime.CompilerServices.Extension()>
  Public Function ToFormsColor(color As Windows.Media.Color) As System.Drawing.Color
    Return System.Drawing.Color.FromArgb(color.A, color.R, color.G, color.B)
  End Function

Example

ExampleWinFormsLabel.BackColor = MyWPFSolidColorBrush.Color.ToFormsColor

Author: Markus Schmitz

Submitted on: 23 mrt 2012

Language: VB

Type: Windows.Media.Color

Views: 2580