StyleDefinition
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:
public class StyleDefinition : INotifyStylePropertyChange, IElementWithStyle, INotifyPropertyChanged
Inheritance: objectStyleDefinition
Implements:
Constructors
Creates a new instance of StyleDefinition of StyleType corresponding to specific DocumentElement
public StyleDefinition(DocumentElement element)
DocumentElement that would be used to determine the StyleType
Creates a new instance of StyleDefinition of StyleType corresponding to specific DocumentElement, with specified Name
public StyleDefinition(string name, DocumentElement element)
Unique Name of the style, that would be used to identify style in StyleRepository collection
elementDocumentElementDocumentElement that would be used to determine the StyleType
Creates a new instance of StyleDefinition of corresponding StyleType and Name (style id).
Creates a new instance of StyleDefinition and copies all relevant property values from the specified StyleDefinition instance.
public StyleDefinition(StyleDefinition styleDefinition)
The instance to copy the properties from.
Creates a new instance of StyleDefinition of corresponding StyleType
public StyleDefinition(StyleType styleType)
StyleType corresponding to the type of document elements this style should apply to
Properties
Gets or sets the base StyleDefinition
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
[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.
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
[XamlSerializable("")]
public string DisplayName { get; set; }
Gets RadDocument that owns this StyleDefinition instance.
public RadDocument Document { get; }
Gets or sets value indicating whether the style is custom user-created
[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.
[XamlSerializable]
public bool IsDefault { get; set; }
Gets or sets value indicating whether the style will be visible in the styles gallery.
[XamlSerializable]
public bool IsPrimary { get; set; }
Gets or sets linked StyleDefinition. Only Paragraph and Character types of styles can be linked
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.
[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
[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.
[XamlSerializable("")]
public string NextStyleName { get; set; }
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
public ParagraphProperties ParagraphProperties { get; set; }
Gets properties related to Spans in the document
public SpanProperties SpanProperties { get; set; }
Gets properties related to Table-cells in the document
public TableCellProperties TableCellProperties { get; set; }
Gets properties related to Tables in the document
public TableProperties TableProperties { get; set; }
Gets properties related to Table-rows in the document
public TableRowProperties TableRowProperties { get; set; }
Gets or sets StyleType corresponding to the type of document elements this style should be applied to.
[XamlSerializable]
public StyleType Type { get; set; }
Gets or sets the UI priority of the style. Negative values will be transformed to zero (0);
[XamlSerializable(10000)]
public int UIPriority { get; set; }
The UI priority.
Methods
Clears local values from all property containers owned by this style.
public void Clear()
Clears this style's local value for one property so its inherited or default value can be used.
public void ClearPropertyValue(IStylePropertyDefinition property)
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.
public void CopyPropertiesFrom(StyleDefinition fromStyleDefinition)
The style definition to copy property values from.
Metod provided for backward compatibility. Please use the provided properties instead.
public StylePropertyBase GetProperty(IStylePropertyDefinition propertyDefinition)
Metod provided for backward compatibility. Please use the provided properties instead.
public object GetPropertyValue(IStylePropertyDefinition propertyDefinition, DocumentElement initialValueEvaluationCaller = null)
Determines the style type associated with a style-aware element or property container.
public static StyleType? GetStyleTypeForElement(IElementWithStyle element)
The element or properties container to inspect.
Returns: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.
public bool IsPropertySet(IStylePropertyDefinition propertyDefinition)
The property to check.
Returns:Merges local property values from another style where this style has no local value.
public void MergePropertiesWith(StyleDefinition definitionToMergeWith)
The style whose local values may be merged.
Raises DisplayNameChanged after the display name changes.
protected virtual void OnDisplayNameChanged(NameChangingEventArgs args)
The old and new display names.
Raises IsPrimaryChanged after the primary-gallery status changes.
protected virtual void OnIsPrimaryChanged()
Updates referenced elements and raises NameChanged after the style name changes.
protected virtual void OnNameChanged(NameChangingEventArgs args)
The old and new style names.
Raises the post-change notification and updates linked-style or conditional-table-style dependents as needed.
protected virtual void OnStylePropertyChanged(IStylePropertyDefinition propertyDefinition, object oldValue, object newValue)
The property that changed.
oldValueobjectThe value before the change.
newValueobjectThe 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.
protected virtual void OnStylePropertyChanging(IStylePropertyDefinition propertyDefinition, object oldValue, object newValue)
The property that is changing.
oldValueobjectThe value before the change.
newValueobjectThe effective value after the change.
Metod provided for backward compatibility. Please use the provided properties instead.
public void SetPropertyValue(IStylePropertyDefinition propertyDefinition, object newValue)
Gets the string representation of this StyleDefinition that can be used to display information about property values.
Events
Occurs after the style's display name changes.
public event EventHandler<NameChangingEventArgs> DisplayNameChanged
Occurs after the style's primary-gallery status changes.
public event EventHandler IsPrimaryChanged
Occurs after the style's identifying name changes.
public event EventHandler<NameChangingEventArgs> NameChanged
Occurs when a style-definition property that supports property-change notification changes.
public event PropertyChangedEventHandler PropertyChanged
Implements:
Occurs after a property value in this style changes.
public event StylePropertyChangeEventHandler StylePropertyChanged
Implements:
Occurs before the corresponding StylePropertyChanged notification. The property value may already have been updated when this event fires.
public event StylePropertyChangeEventHandler StylePropertyChanging
Implements: