New to Telerik UI for WinForms? Start a free 30-day trial

Maintains a document's styles by name, registering base and linked styles and resolving style references as styles are added.

Definition

Namespace:Telerik.WinForms.Documents.Model

Assembly:Telerik.WinControls.RichTextEditor.dll

Syntax:

C#
public class StyleCollection : INotifyCollectionChanged, IEnumerable

Inheritance: objectStyleCollection

Implements: IEnumerableINotifyCollectionChanged

Constructors

Creates a style repository associated with a document.

C#
public StyleCollection(RadDocument document)
Parameters:documentRadDocument

The document that owns the styles.

Properties

Gets the number of styles currently registered.

C#
public int Count { get; }

Gets the document that owns this style repository.

C#
public RadDocument Document { get; }

Gets the style with the specified name, automatically registering it if it is a built-in style.

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

The style name to look up.

Property Value:

The matching style, or null when no matching style is available.

Methods

Registers a style and ensures that its base and linked styles are registered as well.

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

The style to register.

Removes all registered styles, raising collection notifications for the removals.

C#
public void Clear()

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

The registered style, including a built-in style added when autoAddBuiltInStyles is true; otherwise, null if no style is available.

Raises the collection-changed notification.

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

The action and style associated with the collection change.

Removes the named style and also removes its linked style, if present.

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

The name of the style to remove.

Removes a style by its name and also removes its linked style, if present.

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

The style to remove.

Events

Occurs when a style is added to or removed from the repository.

C#
public event NotifyCollectionChangedEventHandler CollectionChanged

Implements: INotifyCollectionChanged.CollectionChanged