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

ToWpfColor

Converts a System.Drawing.Color (e.g. from a ColorDialog) into a System.Windows.Media.Color for WPF

Source

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

Example

If ColorDialog.ShowDialog = Windows.Forms.DialogResult.OK Then
  MyWpfBrushProperty = New Windows.Media.SolidColorBrush(ColorDialog.Color.ToWpfColor)
End If

Author: Markus Schmitz

Submitted on: 23 mrt 2012

Language: VB

Type: System.Drawing.Color

Views: 4185