Skip to main content

Classes Class

Definition

Assembly:Avalonia.Base
Package:Avalonia
Source:Classes.cs

Holds a collection of style classes for an Avalonia.StyledElement.

public class Classes

Inheritance: AvaloniaList<string> -> Classes

Implements:IPseudoClasses

Remarks

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

Constructors

NameDescription
Classes (3 overloads)Initializes a new instance of the Avalonia.Controls.Classes class.

Classes overloads

Classes Constructor

Initializes a new instance of the Avalonia.Controls.Classes class.

public Classes()

Classes Constructor

public Classes(System.Collections.Generic.IEnumerable<string> items)
Parameters

items System.Collections.Generic.IEnumerable<string>

Classes Constructor

Initializes a new instance of the Avalonia.Controls.Classes class.

public Classes(string[] items)
Parameters

items string[]

The initial items.

Methods

NameDescription
AddAdds a style class to the collection.
AddRangeNo summary available.
ClearRemoves all non-pseudoclasses from the collection.
InsertInserts a style class into the collection.
InsertRangeNo summary available.
ParseParses a classes string.
RemoveRemoves a style class from the collection.
RemoveAllNo summary available.
RemoveAtRemoves a style class from the collection.
RemoveRangeRemoves style classes from the collection.
ReplaceNo summary available.
SetAdds a or removes a style class to/from the collection.

Add Method

Adds a style class to the collection.

public 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 Avalonia.StyledElement.PseudoClasses property.

AddRange Method

public void AddRange(System.Collections.Generic.IEnumerable<string> names)

Parameters

names System.Collections.Generic.IEnumerable<string>

Clear Method

Removes all non-pseudoclasses from the collection.

public void Clear()

Insert Method

Inserts a style class into the collection.

public 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 Avalonia.StyledElement.PseudoClasses property.

InsertRange Method

public void InsertRange(int index, System.Collections.Generic.IEnumerable<string> names)

Parameters

index int

names System.Collections.Generic.IEnumerable<string>

Parse Method

Parses a classes string.

public Avalonia.Controls.Classes Parse(string s)

Parameters

s string

The string.

Returns

Avalonia.Controls.Classes

The Avalonia.Controls.Classes.

Remove Method

Removes a style class from the collection.

public 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 Avalonia.StyledElement.PseudoClasses property.

RemoveAll Method

public void RemoveAll(System.Collections.Generic.IEnumerable<string> names)

Parameters

names System.Collections.Generic.IEnumerable<string>

RemoveAt Method

Removes a style class from the collection.

public 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 Avalonia.StyledElement.PseudoClasses property.

RemoveRange Method

Removes style classes from the collection.

public void RemoveRange(int index, int count)

Parameters

index int

The first index to remove.

count int

The number of items to remove.

Replace Method

public void Replace(System.Collections.Generic.IList<string> source)

Parameters

source System.Collections.Generic.IList<string>

Set Method

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 Avalonia.StyledElement.PseudoClasses property.