Class
StyleCollection

Represents a collection of styles that can be applied to document elements.

Definition

Namespace:Telerik.Windows.Documents.Model

Assembly:Telerik.Windows.Controls.RichTextBox.dll

Syntax:

cs-api-definition
public class StyleCollection : INotifyCollectionChanged, IEnumerable<StyleDefinition>, IEnumerable

Inheritance: objectStyleCollection

Implements: IEnumerableIEnumerable<StyleDefinition>INotifyCollectionChanged

Constructors

StyleCollection(RadDocument)

Declaration

cs-api-definition
public StyleCollection(RadDocument document)

Parameters

document

RadDocument

Properties

Count

Gets the number of styles in the collection.

Declaration

cs-api-definition
public int Count { get; }

Property Value

int

Document

Gets the associated RadDocument.

Declaration

cs-api-definition
public RadDocument Document { get; }

Property Value

RadDocument

this[string]

Declaration

cs-api-definition
public StyleDefinition this[string styleName] { get; }

Parameters

styleName

string

Property Value

StyleDefinition

Methods

Add(StyleDefinition)

Adds a new style definition to the collection.

Declaration

cs-api-definition
public void Add(StyleDefinition style)

Parameters

style

StyleDefinition

The style definition to be added to the collection.

Clear()

Removes all styles from the collection.

Declaration

cs-api-definition
public void Clear()

Remarks

This method clears the collection of any previously added styles, leaving it empty. Use this method when you want to reset the style collection.

GetValueOrNull(string, bool)

Get style from the repository by name.

Declaration

cs-api-definition
public StyleDefinition GetValueOrNull(string styleName, bool autoAddBuiltInStyles = true)

Parameters

styleName

string

Name of the style.

autoAddBuiltInStyles

bool

True to automatically add built in styles into the repository.

Returns

StyleDefinition

OnCollectionChanged(NotifyCollectionChangedEventArgs)

Declaration

cs-api-definition
protected virtual void OnCollectionChanged(NotifyCollectionChangedEventArgs args)

Parameters

args

NotifyCollectionChangedEventArgs

Remove(StyleDefinition)

Removes a specified style definition from the style collection.

Declaration

cs-api-definition
public void Remove(StyleDefinition style)

Parameters

style

StyleDefinition

The style definition to be removed from the collection.

Remove(string)

Removes a style from the collection by its name.

Declaration

cs-api-definition
public void Remove(string name)

Parameters

name

string

The name of the style to remove.

Events

CollectionChanged

Declaration

cs-api-definition
public event NotifyCollectionChangedEventHandler CollectionChanged

Event Value

NotifyCollectionChangedEventHandler

Implements INotifyCollectionChanged.CollectionChanged