Table of Contents

Class Styles

Namespace
Avalonia.Styling
Assembly
Avalonia.Base.dll

A style that consists of a number of child styles.

public class Styles : AvaloniaObject, IAvaloniaList<IStyle>, IList<IStyle>, ICollection<IStyle>, IAvaloniaReadOnlyList<IStyle>, IReadOnlyList<IStyle>, IReadOnlyCollection<IStyle>, IEnumerable<IStyle>, IEnumerable, INotifyCollectionChanged, INotifyPropertyChanged, IStyle, IResourceProvider, IResourceNode
Inheritance
Styles
Implements
Inherited Members
Extension Methods

Constructors

Styles()

public Styles()

Styles(IResourceHost)

public Styles(IResourceHost owner)

Parameters

owner IResourceHost

Properties

Count

Gets the number of items in the list.

public int Count { get; }

Property Value

int

this[int]

Gets or sets the element at the specified index.

public IStyle this[int index] { get; set; }

Parameters

index int

The index.

Property Value

IStyle

The element at the requested index.

Owner

Gets the owner of the resource provider.

public IResourceHost? Owner { get; }

Property Value

IResourceHost

Remarks

If multiple owners are added, returns the first.

Resources

Gets or sets a dictionary of style resources.

public IResourceDictionary Resources { get; set; }

Property Value

IResourceDictionary

Methods

Add(IStyle)

public void Add(IStyle item)

Parameters

item IStyle

AddRange(IEnumerable<IStyle>)

Adds multiple items to the collection.

public void AddRange(IEnumerable<IStyle> items)

Parameters

items IEnumerable<IStyle>

The items.

Clear()

public void Clear()

Contains(IStyle)

public bool Contains(IStyle item)

Parameters

item IStyle

Returns

bool

CopyTo(IStyle[], int)

public void CopyTo(IStyle[] array, int arrayIndex)

Parameters

array IStyle[]
arrayIndex int

GetEnumerator()

public AvaloniaList<IStyle>.Enumerator GetEnumerator()

Returns

AvaloniaList<IStyle>.Enumerator

IndexOf(IStyle)

public int IndexOf(IStyle item)

Parameters

item IStyle

Returns

int

Insert(int, IStyle)

public void Insert(int index, IStyle item)

Parameters

index int
item IStyle

InsertRange(int, IEnumerable<IStyle>)

Inserts multiple items at the specified index.

public void InsertRange(int index, IEnumerable<IStyle> items)

Parameters

index int

The index.

items IEnumerable<IStyle>

The items.

Move(int, int)

Moves an item to a new index.

public void Move(int oldIndex, int newIndex)

Parameters

oldIndex int

The index of the item to move.

newIndex int

The index to move the item to.

MoveRange(int, int, int)

Moves multiple items to a new index.

public void MoveRange(int oldIndex, int count, int newIndex)

Parameters

oldIndex int

The first index of the items to move.

count int

The number of items to move.

newIndex int

The index to move the items to.

Remove(IStyle)

public bool Remove(IStyle item)

Parameters

item IStyle

Returns

bool

RemoveAll(IEnumerable<IStyle>)

Removes multiple items from the collection.

public void RemoveAll(IEnumerable<IStyle> items)

Parameters

items IEnumerable<IStyle>

The items.

RemoveAt(int)

public void RemoveAt(int index)

Parameters

index int

RemoveRange(int, int)

Removes a range of elements 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.

TryGetResource(object, ThemeVariant?, out object?)

Tries to find a resource within the object.

public bool TryGetResource(object key, ThemeVariant? theme, out object? value)

Parameters

key object

The resource key.

theme ThemeVariant

Theme used to select theme dictionary.

value object

When this method returns, contains the value associated with the specified key, if the key is found; otherwise, null.

Returns

bool

True if the resource if found, otherwise false.

Events

CollectionChanged

public event NotifyCollectionChangedEventHandler? CollectionChanged

Event Type

NotifyCollectionChangedEventHandler

OwnerChanged

Raised when the Owner of the resource provider changes.

public event EventHandler? OwnerChanged

Event Type

EventHandler