Table of Contents

Class ThemeVariant

Namespace
Avalonia.Styling
Assembly
Avalonia.Base.dll

Specifies a UI theme variant that should be used for the Control and Application types.

[TypeConverter(typeof(ThemeVariantTypeConverter))]
public sealed record ThemeVariant : IEquatable<ThemeVariant>
Inheritance
ThemeVariant
Implements
Inherited Members

Constructors

ThemeVariant(object, ThemeVariant?)

Creates a new instance of the ThemeVariant

public ThemeVariant(object key, ThemeVariant? inheritVariant)

Parameters

key object

Key of the theme variant by which variants are compared.

inheritVariant ThemeVariant

Reference to a theme variant which should be used, if resource wasn't found for the requested variant.

Exceptions

ArgumentException

Thrown if inheritVariant is a reference to the Default which is ambiguous value to inherit.

ArgumentNullException

Thrown if key is null.

Properties

Dark

Use the Dark theme variant.

public static ThemeVariant Dark { get; }

Property Value

ThemeVariant

Default

Inherit theme variant from the parent. If set on Application, system theme is inherited. Using Default as the ResourceDictionary.Key marks this dictionary as a fallback in case the theme variant or resource key is not found in other theme dictionaries.

public static ThemeVariant Default { get; }

Property Value

ThemeVariant

InheritVariant

Reference to a theme variant which should be used, if resource wasn't found for the requested variant.

public ThemeVariant? InheritVariant { get; }

Property Value

ThemeVariant

Key

Key of the theme variant by which variants are compared.

public object Key { get; }

Property Value

object

Light

Use the Light theme variant.

public static ThemeVariant Light { get; }

Property Value

ThemeVariant

Methods

Equals(ThemeVariant?)

public bool Equals(ThemeVariant? other)

Parameters

other ThemeVariant

Returns

bool

Equals(object?)

public override bool Equals(object? obj)

Parameters

obj object

Returns

bool

GetHashCode()

public override int GetHashCode()

Returns

int

ToString()

public override string ToString()

Returns

string

Operators

operator ==(ThemeVariant?, ThemeVariant?)

public static bool operator ==(ThemeVariant? left, ThemeVariant? right)

Parameters

left ThemeVariant
right ThemeVariant

Returns

bool

explicit operator ThemeVariant(PlatformThemeVariant)

public static explicit operator ThemeVariant(PlatformThemeVariant themeVariant)

Parameters

themeVariant PlatformThemeVariant

Returns

ThemeVariant

explicit operator PlatformThemeVariant?(ThemeVariant)

public static explicit operator PlatformThemeVariant?(ThemeVariant themeVariant)

Parameters

themeVariant ThemeVariant

Returns

PlatformThemeVariant?

operator !=(ThemeVariant?, ThemeVariant?)

public static bool operator !=(ThemeVariant? left, ThemeVariant? right)

Parameters

left ThemeVariant
right ThemeVariant

Returns

bool