Table of Contents

Class Classes

Namespace
Avalonia.Controls
Assembly
Avalonia.Base.dll

Holds a collection of style classes for an StyledElement.

public class Classes : AvaloniaList<string>, IAvaloniaList<string>, IList<string>, ICollection<string>, IAvaloniaReadOnlyList<string>, IReadOnlyList<string>, IReadOnlyCollection<string>, IEnumerable<string>, INotifyCollectionChanged, INotifyPropertyChanged, IList, ICollection, IEnumerable, IPseudoClasses
Inheritance
Classes
Implements
Inherited Members
Extension Methods

Remarks

Similar to CSS, each control may have any number of styling classes applied.

Constructors

Classes()

Initializes a new instance of the Classes class.

public Classes()

Classes(IEnumerable<string>)

Initializes a new instance of the Classes class.

public Classes(IEnumerable<string> items)

Parameters

items IEnumerable<string>

The initial items.

Classes(params string[])

Initializes a new instance of the Classes class.

public Classes(params string[] items)

Parameters

items string[]

The initial items.

Methods

Add(string)

Adds a style class to the collection.

public override void Add(string name)

Parameters

name string

The class name.

Remarks

Only standard classes may be added via this method. To add pseudoclasses (classes beginning with a ':' character) use the protected PseudoClasses property.

AddRange(IEnumerable<string>)

Adds a style classes to the collection.

public override void AddRange(IEnumerable<string> names)

Parameters

names IEnumerable<string>

The class names.

Remarks

Only standard classes may be added via this method. To add pseudoclasses (classes beginning with a ':' character) use the protected PseudoClasses property.

Clear()

Removes all non-pseudoclasses from the collection.

public override void Clear()

Insert(int, string)

Inserts a style class into the collection.

public override void Insert(int index, string name)

Parameters

index int

The index to insert the class at.

name string

The class name.

Remarks

Only standard classes may be added via this method. To add pseudoclasses (classes beginning with a ':' character) use the protected PseudoClasses property.

InsertRange(int, IEnumerable<string>)

Inserts style classes into the collection.

public override void InsertRange(int index, IEnumerable<string> names)

Parameters

index int

The index to insert the class at.

names IEnumerable<string>

The class names.

Remarks

Only standard classes may be added via this method. To add pseudoclasses (classes beginning with a ':' character) use the protected PseudoClasses property.

Parse(string)

Parses a classes string.

public static Classes Parse(string s)

Parameters

s string

The string.

Returns

Classes

The Classes.

Remove(string)

Removes a style class from the collection.

public override bool Remove(string name)

Parameters

name string

The class name.

Returns

bool

Remarks

Only standard classes may be removed via this method. To remove pseudoclasses (classes beginning with a ':' character) use the protected PseudoClasses property.

RemoveAll(IEnumerable<string>)

Removes style classes from the collection.

public override void RemoveAll(IEnumerable<string> names)

Parameters

names IEnumerable<string>

The class name.

Remarks

Only standard classes may be removed via this method. To remove pseudoclasses (classes beginning with a ':' character) use the protected PseudoClasses property.

RemoveAt(int)

Removes a style class from the collection.

public override void RemoveAt(int index)

Parameters

index int

The index of the class in the collection.

Remarks

Only standard classes may be removed via this method. To remove pseudoclasses (classes beginning with a ':' character) use the protected PseudoClasses property.

RemoveRange(int, int)

Removes style classes from the collection.

public override void RemoveRange(int index, int count)

Parameters

index int

The first index to remove.

count int

The number of items to remove.

Replace(IList<string>)

Removes all non-pseudoclasses in the collection and adds a new set.

public void Replace(IList<string> source)

Parameters

source IList<string>

The new contents of the collection.

Set(string, bool)

Adds a or removes a style class to/from the collection.

public void Set(string name, bool value)

Parameters

name string

The class names.

value bool

If true adds the class, if false, removes it.

Remarks

Only standard classes may be added or removed via this method. To add pseudoclasses (classes beginning with a ':' character) use the protected PseudoClasses property.