Class
StyleDefinition

Represents a style definition in the Telerik Documents Model, encapsulating style properties such as font, color, and layout settings that can be applied to document elements.

Definition

Namespace:Telerik.Windows.Documents.Model.Styles

Assembly:Telerik.Windows.Controls.RichTextBox.dll

Syntax:

cs-api-definition
public class StyleDefinition : INotifyStylePropertyChange, IElementWithStyle, INotifyPropertyChanged

Inheritance: objectStyleDefinition

Implements: IElementWithStyleINotifyPropertyChangedINotifyStylePropertyChange

Constructors

StyleDefinition(DocumentElement)

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

Declaration

cs-api-definition
public StyleDefinition(DocumentElement element)

Parameters

element

DocumentElement

DocumentElement that would be used to determine the StyleType

StyleDefinition(StyleDefinition)

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

Declaration

cs-api-definition
public StyleDefinition(StyleDefinition styleDefinition)

Parameters

styleDefinition

StyleDefinition

The instance to copy the properties from.

StyleDefinition(StyleType)

Creates a new instance of StyleDefinition of corresponding StyleType

Declaration

cs-api-definition
public StyleDefinition(StyleType styleType)

Parameters

styleType

StyleType

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

StyleDefinition(string, DocumentElement)

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

Declaration

cs-api-definition
public StyleDefinition(string name, DocumentElement element)

Parameters

name

string

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

element

DocumentElement

DocumentElement that would be used to determine the StyleType

StyleDefinition(string, StyleType)

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

Declaration

cs-api-definition
public StyleDefinition(string name, StyleType styleType)

Parameters

name

string

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

styleType

StyleType

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

Properties

BasedOn

Gets or sets the base StyleDefinition

Declaration

cs-api-definition
public StyleDefinition BasedOn { get; set; }

Property Value

StyleDefinition

Remarks

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.

BasedOnName

Gets or sets the name of base style

Declaration

cs-api-definition
[XamlSerializable("")]
public string BasedOnName { get; set; }

Property Value

string

Remarks

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.

ConditionalTableStylesCollection

Represents a collection of conditional table styles that can be applied to tables in a document.

Declaration

cs-api-definition
public ConditionalTableStylesCollection ConditionalTableStylesCollection { get; }

Property Value

ConditionalTableStylesCollection

Remarks

This collection provides functionality to manage and customize styles based on specific conditions.

DisplayName

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

Declaration

cs-api-definition
[XamlSerializable("")]
public string DisplayName { get; set; }

Property Value

string

Document

Gets RadDocument that owns this StyleDefinition instance.

Declaration

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

Property Value

RadDocument

IsCustom

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

Declaration

cs-api-definition
[XamlSerializable]
public bool IsCustom { get; set; }

Property Value

bool

IsDefault

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

Declaration

cs-api-definition
[XamlSerializable]
public bool IsDefault { get; set; }

Property Value

bool

IsPrimary

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

Declaration

cs-api-definition
[XamlSerializable]
public bool IsPrimary { get; set; }

Property Value

bool

LinkedStyle

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

Declaration

cs-api-definition
public StyleDefinition LinkedStyle { get; set; }

Property Value

StyleDefinition

Remarks

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.

LinkedStyleName

Gets or sets the name of the linked style.

Declaration

cs-api-definition
[XamlSerializable("")]
public string LinkedStyleName { get; set; }

Property Value

string

Remarks

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.

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

Declaration

cs-api-definition
[XamlSerializable]
public string Name { get; set; }

Property Value

string

NextStyleName

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

Declaration

cs-api-definition
[XamlSerializable("")]
public string NextStyleName { get; set; }

Property Value

string

The name of the next style.

Remarks

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

ParagraphProperties

Gets properties related to Paragraphs in the document

Declaration

cs-api-definition
public ParagraphProperties ParagraphProperties { get; set; }

Property Value

ParagraphProperties

SpanProperties

Gets properties related to Spans in the document

Declaration

cs-api-definition
public SpanProperties SpanProperties { get; set; }

Property Value

SpanProperties

TableCellProperties

Gets properties related to Table-cells in the document

Declaration

cs-api-definition
public TableCellProperties TableCellProperties { get; set; }

Property Value

TableCellProperties

TableProperties

Gets properties related to Tables in the document

Declaration

cs-api-definition
public TableProperties TableProperties { get; set; }

Property Value

TableProperties

TableRowProperties

Gets properties related to Table-rows in the document

Declaration

cs-api-definition
public TableRowProperties TableRowProperties { get; set; }

Property Value

TableRowProperties

Type

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

Declaration

cs-api-definition
[XamlSerializable]
public StyleType Type { get; set; }

Property Value

StyleType

UIPriority

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

Declaration

cs-api-definition
[XamlSerializable(10000)]
public int UIPriority { get; set; }

Property Value

int

The UI priority.

Methods

Clear()

Clears all styles from the current style definition.

Declaration

cs-api-definition
public void Clear()

ClearPropertyValue(IStylePropertyDefinition)

Clears the value of the specified style property for the current style definition.

Declaration

cs-api-definition
public void ClearPropertyValue(IStylePropertyDefinition property)

Parameters

property

IStylePropertyDefinition

The style property definition whose value should be cleared.

CopyPropertiesFrom(StyleDefinition)

Copies properties from the specified StyleDefinition to the current instance.

Declaration

cs-api-definition
public void CopyPropertiesFrom(StyleDefinition fromStyleDefinition)

Parameters

fromStyleDefinition

StyleDefinition

The StyleDefinition from which properties will be copied.

GetProperty(IStylePropertyDefinition)

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

Declaration

cs-api-definition
public StylePropertyBase GetProperty(IStylePropertyDefinition propertyDefinition)

Parameters

propertyDefinition

IStylePropertyDefinition

Returns

StylePropertyBase

GetPropertyValue(IStylePropertyDefinition, DocumentElement)

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

Declaration

cs-api-definition
public object GetPropertyValue(IStylePropertyDefinition propertyDefinition, DocumentElement initialValueEvaluationCaller = null)

Parameters

propertyDefinition

IStylePropertyDefinition

initialValueEvaluationCaller

DocumentElement

Returns

object

GetStyleTypeForElement(IElementWithStyle)

Retrieves the style type associated with the specified element that has a style.

Declaration

cs-api-definition
public static StyleType? GetStyleTypeForElement(IElementWithStyle element)

Parameters

element

IElementWithStyle

The element for which to retrieve the style type. It must implement IElementWithStyle.

Returns

StyleType?

The style type corresponding to the specified element.

IsPropertySet(IStylePropertyDefinition)

Determines whether the specified style property is set in the style definition.

Declaration

cs-api-definition
public bool IsPropertySet(IStylePropertyDefinition propertyDefinition)

Parameters

propertyDefinition

IStylePropertyDefinition

The style property definition to check.

Returns

bool

True if the specified style property is set; otherwise, false.

MergePropertiesWith(StyleDefinition)

Merges the properties of the specified style definition with the current style definition.

Declaration

cs-api-definition
public void MergePropertiesWith(StyleDefinition definitionToMergeWith)

Parameters

definitionToMergeWith

StyleDefinition

The style definition to merge with the current one.

OnDisplayNameChanged(NameChangingEventArgs)

Declaration

cs-api-definition
protected virtual void OnDisplayNameChanged(NameChangingEventArgs args)

Parameters

args

NameChangingEventArgs

OnIsPrimaryChanged()

Declaration

cs-api-definition
protected virtual void OnIsPrimaryChanged()

OnNameChanged(NameChangingEventArgs)

Declaration

cs-api-definition
protected virtual void OnNameChanged(NameChangingEventArgs args)

Parameters

args

NameChangingEventArgs

OnStylePropertyChanged(IStylePropertyDefinition, object, object)

Declaration

cs-api-definition
protected virtual void OnStylePropertyChanged(IStylePropertyDefinition propertyDefinition, object oldValue, object newValue)

Parameters

propertyDefinition

IStylePropertyDefinition

oldValue

object

newValue

object

OnStylePropertyChanging(IStylePropertyDefinition, object, object)

Declaration

cs-api-definition
protected virtual void OnStylePropertyChanging(IStylePropertyDefinition propertyDefinition, object oldValue, object newValue)

Parameters

propertyDefinition

IStylePropertyDefinition

oldValue

object

newValue

object

SetPropertyValue(IStylePropertyDefinition, object)

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

Declaration

cs-api-definition
public void SetPropertyValue(IStylePropertyDefinition propertyDefinition, object newValue)

Parameters

propertyDefinition

IStylePropertyDefinition

newValue

object

ToString()

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

Declaration

cs-api-definition
public override string ToString()

Returns

string

Overrides object.ToString()

Events

DisplayNameChanged

Declaration

cs-api-definition
public event EventHandler<NameChangingEventArgs> DisplayNameChanged

Event Value

EventHandler<NameChangingEventArgs>

IsPrimaryChanged

Declaration

cs-api-definition
public event EventHandler IsPrimaryChanged

Event Value

EventHandler

NameChanged

Declaration

cs-api-definition
public event EventHandler<NameChangingEventArgs> NameChanged

Event Value

EventHandler<NameChangingEventArgs>

PropertyChanged

Declaration

cs-api-definition
public event PropertyChangedEventHandler PropertyChanged

Event Value

PropertyChangedEventHandler

Implements INotifyPropertyChanged.PropertyChanged

StylePropertyChanged

Declaration

cs-api-definition
public event StylePropertyChangeEventHandler StylePropertyChanged

Event Value

StylePropertyChangeEventHandler

Implements INotifyStylePropertyChange.StylePropertyChanged

StylePropertyChanging

Declaration

cs-api-definition
public event StylePropertyChangeEventHandler StylePropertyChanging

Event Value

StylePropertyChangeEventHandler

Implements INotifyStylePropertyChange.StylePropertyChanging

Extension Methods