ClassVisualElement
Extends RadElement with visual properties and rendering capabilities common to all visual elements.
Definition
Namespace:Telerik.WinControls
Assembly:Telerik.WinControls.dll
Syntax:
public class VisualElement : RadElement, IDisposable, INotifyPropertyChanged, ICustomTypeDescriptor, ISupportSystemSkin, IStylableNode
Inheritance: objectDisposableObjectRadObjectRadElementVisualElement
Derived Classes:
Implements:
Inherited Members
Constructors
VisualElement()
Declaration
public VisualElement()
Fields
BackColorProperty
Identifies the BackColor dependency property. This property represents the background color used for filling the element.
Declaration
public static RadProperty BackColorProperty
Field Value
Remarks
This is an attached property that can be inherited through the element tree. Changes to this property will trigger display updates.
CustomFontProperty
Identifies the CustomFont dependency property. This property specifies the name of a custom font to use.
Declaration
public static RadProperty CustomFontProperty
Field Value
Remarks
The default value is "None", which means no custom font is used. When set to a valid font name, it overrides the standard Font property.
CustomFontSizeProperty
Identifies the CustomFontSize dependency property. This property specifies the size of the custom font.
Declaration
public static RadProperty CustomFontSizeProperty
Field Value
Remarks
The default value is 12.0f. This property is used in conjunction with CustomFont.
CustomFontStyleProperty
Identifies the CustomFontStyle dependency property. This property specifies the style of the custom font.
Declaration
public static RadProperty CustomFontStyleProperty
Field Value
Remarks
The default value is FontStyle.Regular. This property is used in conjunction with CustomFont.
DefaultSizeProperty
Identifies the DefaultSize dependency property. This property represents the default size of a VisualElement. When set, this property affects display, parent arrangement, and measurement calculations.
Declaration
public static RadProperty DefaultSizeProperty
Field Value
Remarks
This is an attached property that can be applied to any VisualElement. The default value is Size.Empty. When changed, it will trigger layout recalculation because it has the AffectsDisplay, AffectsParentArrange, and AffectsMeasure property options.
FontProperty
Identifies the Font dependency property. This property represents the font used for rendering text.
Declaration
public static RadProperty FontProperty
Field Value
Remarks
This property has significant impact on layout and display. Changes to this property will trigger measurement, layout recalculation, and display updates. It can be inherited from parent elements.
ForeColorProperty
Identifies the ForeColor dependency property. This property represents the foreground color used for rendering text and borders.
Declaration
public static RadProperty ForeColorProperty
Field Value
Remarks
This property can inherit its value from parent elements and affects the display of the element when changed.
OpacityProperty
Identifies the Opacity dependency property. This property determines the transparency level of the element.
Declaration
public static RadProperty OpacityProperty
Field Value
Remarks
The value ranges from 0.0 (completely transparent) to 1.0 (completely opaque). Changes to this property affect how the element and its children are displayed.
SmoothingModeProperty
Identifies the SmoothingMode dependency property. This property determines how graphics are smoothed when rendered.
Declaration
public static RadProperty SmoothingModeProperty
Field Value
Remarks
Changes to this property affect the visual quality of rendered graphics. The default value is SmoothingMode.Default.
Properties
BackColor
Gets or sets the background color of the element.
Declaration
[TypeConverter(typeof(RadColorEditorConverter))]
public virtual Color BackColor { get; set; }
Property Value
A Color that represents the background color of the element. The default value is determined by the current theme.
Remarks
This property is inheritable through the element tree, allowing child elements to inherit the background color from their parents unless explicitly overridden.
CustomFont
Gets or sets the name of the custom font to be used for rendering text in this element.
Declaration
[VsbBrowsable(true)]
[TypeConverter(typeof(CustomFontTypeConverter))]
public virtual string CustomFont { get; set; }
Property Value
Remarks
This property works in conjunction with CustomFontSize and CustomFontStyle to define a custom font. Setting this property to a font name other than "None" will override the Font property. Available values include standard fonts like "Roboto" and icon fonts like "Telerik Web UI" and "Font Awesome".
CustomFontSize
Gets or sets the size of the custom font in points.
Declaration
[VsbBrowsable(true)]
public virtual float CustomFontSize { get; set; }
Property Value
Remarks
This property is used when CustomFont is set to a value other than "None". The default size is 12 points.
CustomFontStyle
Gets or sets the style for the custom font.
Declaration
[VsbBrowsable(true)]
public virtual FontStyle CustomFontStyle { get; set; }
Property Value
Remarks
This property is used when CustomFont is set to a value other than "None". The default style is Regular, but can be set to other FontStyle values like Bold, Italic, etc.
DefaultSize
Gets or sets the default size for the visual element.
Declaration
public virtual Size DefaultSize { get; set; }
Property Value
Remarks
The default size is used as the preferred size when measuring and arranging elements. This property is inheritable through the element tree and affects layout calculations.
Font
Gets or sets the font used for rendering text in this element.
Declaration
public virtual Font Font { get; set; }
Property Value
A Font object that defines the text format including font face, size, and style attributes. The default value is determined by the current theme or system default font.
Remarks
This property is inheritable through the element tree and has significant impact on layout calculations. Setting the font to null will reset it to the inherited or default value.
ForeColor
Gets or sets the foreground color of the element.
Declaration
[TypeConverter(typeof(RadColorEditorConverter))]
public virtual Color ForeColor { get; set; }
Property Value
A Color that represents the foreground color used for text and borders. The default value is determined by the current theme.
Remarks
This property is inheritable through the element tree, allowing child elements to inherit the foreground color from their parents unless explicitly overridden. The foreground color affects text rendering and border appearance.
Opacity
Gets or sets the opacity of an element. Value 0.0f indicates that the element is completely transparent, 1.0f means the element is not transparent (the default value).
SmoothingMode
Gets or sets the smoothing mode of an element. Smoothing mode enumeration defines possible values.
Declaration
public virtual SmoothingMode SmoothingMode { get; set; }
Property Value
Methods
GetScaledFont(float)
Creates a scaled version of the element's font based on the provided scale factor.
Declaration
public virtual Font GetScaledFont(float scale)
Parameters
scale
The scale factor to apply to the font.
Returns
A new Font object with size adjusted according to the scale factor.
Remarks
This method applies DPI scaling if enabled. It's useful when rendering text at different zoom levels or on displays with different pixel densities.
GetScaledFont(float, Font)
Creates a scaled version of the specified font based on the provided scale factor.
OnFontChanged(EventArgs)
Raises the FontChanged event.
OnPropertyChanged(RadPropertyChangedEventArgs)
Called when a property value has changed, allowing for custom response to property changes.
Declaration
protected override void OnPropertyChanged(RadPropertyChangedEventArgs e)
Parameters
e
The property changed event arguments.
Overrides
OnPropertyChanging(RadPropertyChangingEventArgs)
Called before a property value is changed, allowing for validation or cancellation.
Declaration
protected override void OnPropertyChanging(RadPropertyChangingEventArgs args)
Parameters
args
The property changing event arguments.
Overrides
PaintChildren(IGraphics, Rectangle, float, SizeF, bool)
Paints the child elements of this visual element with opacity support.
Declaration
protected override void PaintChildren(IGraphics graphics, Rectangle clipRectangle, float angle, SizeF scale, bool useRelativeTransformation)
Parameters
graphics
The graphics object used for painting.
clipRectangle
The clipping rectangle that limits the painting area.
angle
The rotation angle to apply during painting.
scale
The scale factor to apply during painting.
useRelativeTransformation
True to use relative transformation; otherwise, false.
Overrides
PaintElement(IGraphics, float, SizeF)
Paints the element's background and calls the base implementation to paint child elements.
Declaration
protected override void PaintElement(IGraphics graphics, float angle, SizeF scale)
Parameters
graphics
The graphics object used for painting.
angle
The rotation angle to apply during painting.
scale
The scale factor to apply during painting.
Overrides
PostPaintElement(IGraphics)
Performs post-painting cleanup operations including restoring smoothing mode and opacity.
Declaration
protected override void PostPaintElement(IGraphics graphics)
Parameters
graphics
The graphics object used for painting.
Overrides
PrePaintElement(IGraphics)
Performs pre-painting operations including setting smoothing mode and opacity.
Declaration
protected override void PrePaintElement(IGraphics graphics)
Parameters
graphics
The graphics object used for painting.
Overrides
Events
FontChanged
Occurs when the Font property value changes.