Class
ColorGroup
Description
The ColorGroup class allows you to do dynamic light/dark target color selection.
Properties
Name |
Type |
Read-Only |
Shared |
---|---|---|---|
Methods
Name |
Parameters |
Returns |
Shared |
---|---|---|---|
platform As Platforms, lightColor As Color, darkColor As Color |
|||
defaultColor As Color |
|||
name As String |
|||
platform As Platforms = Platforms.Current |
|||
name As String |
✓ |
||
Delegate Methods
Name |
Parameters |
Returns |
---|---|---|
Enumerations
ColorGroup.Modes
Modes
The mode for the color group (Single, Dual, Named).
Enum |
Description |
---|---|
Single |
A single color. |
Dual |
A dual color has separate colors for light and dark modes. |
Named |
Refers to an OS system color name. |
None |
No color is selected. |
ColorGroup.Platforms
Platforms
The platform for the color group.
Enum |
Description |
---|---|
Current |
The current platform. |
Default |
The default platform. |
Desktop |
Desktop apps. |
Mobile |
Mobile (iOS) apps. |
Web |
Web apps. |
Property descriptions
ColorGroup.UndefinedColorCallback
UndefinedColorCallback As UndefinedColorDelegate
Set a delegate here to have it be called if a specified named color is undefined.
Method descriptions
ColorGroup.AddColor
AddColor(platform As Platforms, aColor As Color)
Adds a single color to a color group.
ColorGroup.AddColorPair
AddColorPair(platform As Platforms, lightColor As Color, darkColor As Color)
Adds a dual color to a color group.
ColorGroup.AddNamedColor
AddNamedColor(platform As Platforms, name As String)
Adds a named color to a color group.
Note
On iOS if you provide a name for a color that is not supported on the device, the appropriate color as defined in iOS 13 will be returned.
ColorGroup.Constructor
Constructor(defaultColor As Color)
Creates a single mode ColorGroup with the specified color.
Note
Constructors are special methods called when you create an object with the New keyword and pass in the parameters above.
ColorGroup.Constructor
Constructor(defaultLightColor As Color, defaultDarkColor As Color)
Creates a dual mode ColorGroup with the specified light and dark colors.
Note
Constructors are special methods called when you create an object with the New keyword and pass in the parameters above.
ColorGroup.Constructor
Constructor(name As String)
Creates a named mode ColorGroup with the specified named color.
If you provide a name for a color that is not supported on the device, the appropriate color as defined in iOS 13 will be returned.
Note
Constructors are special methods called when you create an object with the New keyword and pass in the parameters above.
ColorGroup.Mode
Mode(platform As Platforms = Platforms.Current) As Modes
The mode for the color group.
ColorGroup.Name
Name As String
The name for the color group.
ColorGroup.NamedColor
NamedColor(name As String) As Color
Returns the specified named color.
This method is shared.
Raises these exceptions:
UnsupportedOperationException on platforms that don't support named colors.
InvalidArgumentException when passing a name that isn't available on the current platform.
Apple provides documentation for named colors for MacOS.
Additionally primaryContentBackgroundColor
and secondaryContentBackgroundColor
are valid names specifically for the macOS alternating table row background colors.
For the web, Web Basic, Web Extended and Bootstrap color names can also be used. When using Bootstrap colors, NamedColor will automatically strip off any --bs-
prefix or -rgb
suffix.
ColorGroup.Values
Values As Color()
The color values for the current platform of the color group.
Delegate descriptions
ColorGroup.UndefinedColorDelegate
UndefinedColorDelegate(ByRef c As Color) As Boolean
Specifies a delegate method that can be called when a named color is undefined.
Notes
Comparisons and conversions
A ColorGroup can be directly compared to a Color value to determine if they are the same. It's important to remember of course that you can comparing the known color to the color of the ColorGroup at that moment as a ColorGroup can return different colors based upon the state of the device.
If myColorGroup = Color.Blue Then
Canvas1.DrawingColor = Color.Blue
Else
Canvas1.DrawingColor = Color.Red
End If
When you assign a ColorGroup to a Color property or variable, the color you receive the is color at that moment. For example, in a ColorGroup set to dual color, if you ask for the color when the device is in dark mode, you'll get the dark color.
Assigning a color to a ColorGroup assigns it to the Light Color (the default).
You can assign a named color to a ColorGroup by setting the ColorGroup equal to the name:
myColorGroup = "Link"
For macOS and iOS, Apple provides a complete list of valid named colors. These colors will automatically switch between light and dark modes. Apple's Adaptable System Colors will also automatically switch between light and dark modes but the Fixed Colors will not.
When using a name from Apple's documentation, the case must match as well.
Compatibility
Desktop, console, web and iOS project types on all supported operating systems.
See also
Object parent class; Color data type; Supporting Dark Mode and More with Color Groups, Supporting Dark Mode topics