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

Defines reusable formatting for document elements, including style identity, type, inheritance links, and property data.

Definition

Namespace:Telerik.WinForms.Documents.Model.Styles

Assembly:Telerik.WinControls.RichTextEditor.dll

Syntax:

C#
public class StyleDefinition : INotifyStylePropertyChange, IElementWithStyle, INotifyPropertyChanged

Inheritance: objectStyleDefinition

Implements: IElementWithStyleINotifyPropertyChangedINotifyStylePropertyChange

Constructors

Creates a new instance of StyleDefinition of StyleType corresponding to specific DocumentElement

C#
public StyleDefinition(DocumentElement element)
Parameters:elementDocumentElement

DocumentElement that would be used to determine the StyleType

Creates a new instance of StyleDefinition of StyleType corresponding to specific DocumentElement, with specified Name

C#
public StyleDefinition(string name, DocumentElement element)
Parameters:namestring

Unique Name of the style, that would be used to identify style in StyleRepository collection

elementDocumentElement

DocumentElement that would be used to determine the StyleType

Creates a new instance of StyleDefinition of corresponding StyleType and Name (style id).

C#
public StyleDefinition(string name, StyleType styleType)
Parameters:namestring

Unique Name of the style, that would be used to identify style in StyleRepository collection

styleTypeStyleType

StyleType corresponding to the type of document elements this style should apply to

Creates a new instance of StyleDefinition and copies all relevant property values from the specified StyleDefinition instance.

C#
public StyleDefinition(StyleDefinition styleDefinition)
Parameters:styleDefinitionStyleDefinition

The instance to copy the properties from.

Creates a new instance of StyleDefinition of corresponding StyleType

C#
public StyleDefinition(StyleType styleType)
Parameters:styleTypeStyleType

StyleType corresponding to the type of document elements this style should apply to

Properties

Gets or sets the base StyleDefinition

C#
public StyleDefinition BasedOn { get; set; }

StyleDefinition inherits its property values from BasedOn style. Either BasedOn or BasedOnName can be specified. If BasedOnName is specified BasedOn StyleDefinition would be set automatically if this style definition is added to a document StyleRepository that contains StyleDefinition with corresponding Name.

Gets or sets the name of base style

C#
[XamlSerializable("")]
public string BasedOnName { get; set; }

StyleDefinition inherits its property values from BasedOn style. Either BasedOn or BasedOnName can be specified. If BasedOnName is specified BasedOn StyleDefinition would be set automatically if this style definition is added to a document StyleRepository that contains StyleDefinition with corresponding Name.

Gets the conditional styles that format specific table rows, columns, bands, and corner cells.

C#
public ConditionalTableStylesCollection ConditionalTableStylesCollection { get; }

Gets or sets value corresponding to the name of the style, that would be displayed in Styles dialog, style gallery and other parts of the UI

C#
[XamlSerializable("")]
public string DisplayName { get; set; }

Gets RadDocument that owns this StyleDefinition instance.

C#
public RadDocument Document { get; }

Gets or sets value indicating whether the style is custom user-created

C#
[XamlSerializable]
public bool IsCustom { get; set; }

Gets or sets value indicating whether the style will be applied by default to the document elements of type corresponding to style's Type.

C#
[XamlSerializable]
public bool IsDefault { get; set; }

Gets or sets value indicating whether the style will be visible in the styles gallery.

C#
[XamlSerializable]
public bool IsPrimary { get; set; }

Gets or sets linked StyleDefinition. Only Paragraph and Character types of styles can be linked

C#
public StyleDefinition LinkedStyle { get; set; }

This property can be set to Paragraph or Character style only. Paragraph style can be linked only to Character style and vice versa. StyleDefinition would obtain the corresponding property values from the linked style. Either LenkedStyle or LinkedStyleName can be specified. If BasedOnName is specified BasedOn StyleDefinition would be set automatically if this style definition is added to a document StyleRepository that contains StyleDefinition with corresponding Name.

Gets or sets the name of the linked style.

C#
[XamlSerializable("")]
public string LinkedStyleName { get; set; }

This property can be set to Paragraph or Character style only. Paragraph style can be linked only to Character style and vice versa. StyleDefinition would obtain the corresponding property values from the linked style. Either LinkedStyle or LinkedStyleName can be specified. If BasedOnName is specified BasedOn StyleDefinition would be set automatically if this style definition is added to a document StyleRepository that contains StyleDefinition with corresponding Name.

Gets or sets value corresponding to the unique name of the style, that would be used to identify style in StyleRepository collection in the document

C#
[XamlSerializable]
public string Name { get; set; }

Gets or sets the style which shall automatically be applied to a new paragraph created following a paragraph with this style.

C#
[XamlSerializable("")]
public string NextStyleName { get; set; }
Property Value:

The name of the next style.

This property will have effect when set to Paragraph style only.

Gets properties related to Paragraphs in the document

C#
public ParagraphProperties ParagraphProperties { get; set; }

Gets properties related to Spans in the document

C#
public SpanProperties SpanProperties { get; set; }

Gets properties related to Table-cells in the document

C#
public TableCellProperties TableCellProperties { get; set; }

Gets properties related to Tables in the document

C#
public TableProperties TableProperties { get; set; }

Gets properties related to Table-rows in the document

C#
public TableRowProperties TableRowProperties { get; set; }

Gets or sets StyleType corresponding to the type of document elements this style should be applied to.

C#
[XamlSerializable]
public StyleType Type { get; set; }

Gets or sets the UI priority of the style. Negative values will be transformed to zero (0);

C#
[XamlSerializable(10000)]
public int UIPriority { get; set; }
Property Value:

The UI priority.

Methods

Clears local values from all property containers owned by this style.

C#
public void Clear()

Clears this style's local value for one property so its inherited or default value can be used.

C#
public void ClearPropertyValue(IStylePropertyDefinition property)
Parameters:propertyIStylePropertyDefinition

The property whose local value is cleared.

Copies explicit local formatting-property values from compatible property containers in another style definition. Values inherited from a base style or supplied by defaults are not copied.

C#
public void CopyPropertiesFrom(StyleDefinition fromStyleDefinition)
Parameters:fromStyleDefinitionStyleDefinition

The style definition to copy property values from.

Metod provided for backward compatibility. Please use the provided properties instead.

C#
public StylePropertyBase GetProperty(IStylePropertyDefinition propertyDefinition)
Parameters:propertyDefinitionIStylePropertyDefinitionReturns:

StylePropertyBase

Metod provided for backward compatibility. Please use the provided properties instead.

C#
public object GetPropertyValue(IStylePropertyDefinition propertyDefinition, DocumentElement initialValueEvaluationCaller = null)
Parameters:propertyDefinitionIStylePropertyDefinitioninitialValueEvaluationCallerDocumentElementReturns:

object

Determines the style type associated with a style-aware element or property container.

C#
public static StyleType? GetStyleTypeForElement(IElementWithStyle element)
Parameters:elementIElementWithStyle

The element or properties container to inspect.

Returns:

StyleType?

The matching style type, or null when the type is unsupported or cannot be resolved.

Gets whether this style has a local value for the specified property.

C#
public bool IsPropertySet(IStylePropertyDefinition propertyDefinition)
Parameters:propertyDefinitionIStylePropertyDefinition

The property to check.

Returns:

bool

true if the style defines a local value; otherwise, false.

Merges local property values from another style where this style has no local value.

C#
public void MergePropertiesWith(StyleDefinition definitionToMergeWith)
Parameters:definitionToMergeWithStyleDefinition

The style whose local values may be merged.

Raises DisplayNameChanged after the display name changes.

C#
protected virtual void OnDisplayNameChanged(NameChangingEventArgs args)
Parameters:argsNameChangingEventArgs

The old and new display names.

Raises IsPrimaryChanged after the primary-gallery status changes.

C#
protected virtual void OnIsPrimaryChanged()

Updates referenced elements and raises NameChanged after the style name changes.

C#
protected virtual void OnNameChanged(NameChangingEventArgs args)
Parameters:argsNameChangingEventArgs

The old and new style names.

Raises the post-change notification and updates linked-style or conditional-table-style dependents as needed.

C#
protected virtual void OnStylePropertyChanged(IStylePropertyDefinition propertyDefinition, object oldValue, object newValue)
Parameters:propertyDefinitionIStylePropertyDefinition

The property that changed.

oldValueobject

The value before the change.

newValueobject

The value after the change.

Raises the changing notification for a style property and its referenced elements. The property's effective value may already have been updated.

C#
protected virtual void OnStylePropertyChanging(IStylePropertyDefinition propertyDefinition, object oldValue, object newValue)
Parameters:propertyDefinitionIStylePropertyDefinition

The property that is changing.

oldValueobject

The value before the change.

newValueobject

The effective value after the change.

Metod provided for backward compatibility. Please use the provided properties instead.

C#
public void SetPropertyValue(IStylePropertyDefinition propertyDefinition, object newValue)
Parameters:propertyDefinitionIStylePropertyDefinitionnewValueobject

Gets the string representation of this StyleDefinition that can be used to display information about property values.

C#
public override string ToString()
Returns:

string

Overrides: object.ToString()

Events

Occurs after the style's display name changes.

C#
public event EventHandler<NameChangingEventArgs> DisplayNameChanged

Occurs after the style's primary-gallery status changes.

C#
public event EventHandler IsPrimaryChanged

Occurs after the style's identifying name changes.

C#
public event EventHandler<NameChangingEventArgs> NameChanged

Occurs when a style-definition property that supports property-change notification changes.

C#
public event PropertyChangedEventHandler PropertyChanged

Implements: INotifyPropertyChanged.PropertyChanged

Occurs after a property value in this style changes.

C#
public event StylePropertyChangeEventHandler StylePropertyChanged

Implements: INotifyStylePropertyChange.StylePropertyChanged

Occurs before the corresponding StylePropertyChanged notification. The property value may already have been updated when this event fires.

C#
public event StylePropertyChangeEventHandler StylePropertyChanging

Implements: INotifyStylePropertyChange.StylePropertyChanging

Extension Methods