New to Telerik UI for WPFStart a free 30-day trial

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:

C#
public class StyleCollection : INotifyCollectionChanged, IEnumerable<StyleDefinition>, IEnumerable

Inheritance: objectStyleCollection

Implements: IEnumerableIEnumerable<StyleDefinition>INotifyCollectionChanged

Constructors

C#
public StyleCollection(RadDocument document)
Parameters:documentRadDocument

Properties

Gets the number of styles in the collection.

C#
public int Count { get; }

Gets the associated RadDocument.

C#
public RadDocument Document { get; }
C#
public StyleDefinition this[string styleName] { get; }
Parameters:styleNamestring

Methods

Adds a new style definition to the collection.

C#
public void Add(StyleDefinition style)
Parameters:styleStyleDefinition

The style definition to be added to the collection.

Removes all styles from the collection.

C#
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.

Get style from the repository by name.

C#
public StyleDefinition GetValueOrNull(string styleName, bool autoAddBuiltInStyles = true)
Parameters:styleNamestring

Name of the style.

autoAddBuiltInStylesbool

True to automatically add built in styles into the repository.

Returns:

StyleDefinition

C#
protected virtual void OnCollectionChanged(NotifyCollectionChangedEventArgs args)
Parameters:argsNotifyCollectionChangedEventArgs

Removes a style from the collection by its name.

C#
public void Remove(string name)
Parameters:namestring

The name of the style to remove.

Removes a specified style definition from the style collection.

C#
public void Remove(StyleDefinition style)
Parameters:styleStyleDefinition

The style definition to be removed from the collection.

Events

C#
public event NotifyCollectionChangedEventHandler CollectionChanged

Implements: INotifyCollectionChanged.CollectionChanged