In This Article

ModernTheme Class

Includes all of the resources for Actipro's Modern theme.

public class ModernTheme : Styles, IAvaloniaList<IStyle>, IAvaloniaReadOnlyList<IStyle>, IStyle, IResourceProvider, IResourceNode
Inheritance:
object AvaloniaObject Styles object
Implements:
IAvaloniaList<IStyle> IAvaloniaReadOnlyList<IStyle> IStyle IResourceProvider IResourceNode

Constructors

ModernTheme(IServiceProvider?)

Initializes an instance of the class.

public ModernTheme(IServiceProvider? serviceProvider = null)
Parameter Type Description
serviceProvider IServiceProvider

The parent's service provider.

Properties

AreNativeControlThemesEnabled

Whether control themes for native controls should be enabled.

public bool AreNativeControlThemesEnabled { get; set; }

Property Value

bool:

The default value is true.

Definition

A ThemeDefinition that contains options for generating theme resources.

public ThemeDefinition? Definition { get; set; }

Property Value

ThemeDefinition

Remarks

Theme resources are automatically refreshed when this property is set. If properties on the current ThemeDefinition instance are changed but this Definition property is not set, the RefreshResources() method should be invoked to manually refresh the theme resources.

Includes

A ThemeStyleIncludes that specifies the styles to include from various additional Actipro assemblies that are used within the application.

public ThemeStyleIncludes Includes { get; set; }

Property Value

ThemeStyleIncludes:

The default value is None.

Methods

RefreshResources()

Refreshes the active theme resources by running the theme generator again.

public void RefreshResources()

Remarks

This method should be called after properties are changed on the ThemeDefinition instance in the Definition property. This method does not need to be called if a completely different ThemeDefinition instance will be swapped into the Definition property, since a refresh automatically occurs in that scenario.

TryGetCurrent(out ModernTheme?)

Tries to locate the ModernTheme instance within the Avalonia.Application.Styles collection.

public static bool TryGetCurrent(out ModernTheme? modernTheme)
Parameter Type Description
modernTheme ModernTheme

Returns the ModernTheme instance that was found, if any.

Returns

bool:

true if a ModernTheme instance was found; otherwise, false.

Fields

AreNativeControlThemesEnabledProperty

Defines the AreNativeControlThemesEnabled property.

public static readonly StyledProperty<bool> AreNativeControlThemesEnabledProperty

DefinitionProperty

Defines the Definition property.

public static readonly StyledProperty<ThemeDefinition?> DefinitionProperty

IncludesProperty

Defines the Includes property.

public static readonly StyledProperty<ThemeStyleIncludes> IncludesProperty

Inherited Members

Extension Methods