ColorTypeConverter ColorTypeConverter Class

Definition

A TypeConverter that converts from strings to a Color.

[Xamarin.Forms.Xaml.TypeConversion(typeof(Xamarin.Forms.Color))]
public class ColorTypeConverter : Xamarin.Forms.TypeConverter
type ColorTypeConverter = class
    inherit TypeConverter
Inheritance
ColorTypeConverterColorTypeConverter
Attributes

Remarks

The following example shows some variations of ColorTypeConverter:


var converter = new ColorTypeConverter ();
Assert.True (converter.CanConvertFrom (typeof(string)));
Assert.AreEqual (Color.Blue, converter.ConvertFrom ("Color.Blue"));
Assert.AreEqual (Color.Blue, converter.ConvertFrom ("Blue"));
Assert.AreEqual (Color.Blue, converter.ConvertFrom ("#0000ff"));
Assert.AreEqual (Color.Default, converter.ConvertFrom ("Color.Default"));
Assert.AreEqual (Color.Accent, converter.ConvertFrom ("Accent"));
var hotpink = Color.FromHex ("#FF69B4");
Color.Accent = hotpink;
Assert.AreEqual (Color.Accent, converter.ConvertFrom ("Accent"));          
          

Constructors

ColorTypeConverter() ColorTypeConverter()

Creates a new ColorTypeConverter with default values.

Methods

CanConvertFrom(Type) CanConvertFrom(Type)

When implemented in a derived class, returns a Boolean value that indicates whether or not the derived type converter can convert sourceType to its target type.

(Inherited from TypeConverter)
ConvertFrom(CultureInfo, Object) ConvertFrom(CultureInfo, Object)

When implemented in a derived class, converts an object that is a version of value and that can be cast to the target type.

(Inherited from TypeConverter)
ConvertFrom(Object) ConvertFrom(Object)

Calls Xamarin.Forms.TypeConverter.ConvertFrom(System.Globalization.CultureInfo, object) with the current culture information and o.

(Inherited from TypeConverter)
ConvertFromInvariantString(String) ConvertFromInvariantString(String)

Creates a color from a valid color name.

Extension Methods

LoadFromXaml<TXaml>(TXaml, String) LoadFromXaml<TXaml>(TXaml, String)

Returns an initialized view by loading the specified xaml.

LoadFromXaml<TXaml>(TXaml, Type) LoadFromXaml<TXaml>(TXaml, Type)

Returns a TXaml with the properties that are defined in the application manifest for callingType.

Applies to