VisualElement
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
public VisualElement()
Fields
Identifies the BackColor dependency property. This property represents the background color used for filling the element.
public static RadProperty BackColorProperty
This is an attached property that can be inherited through the element tree. Changes to this property will trigger display updates.
Identifies the CustomFont dependency property. This property specifies the name of a custom font to use.
public static RadProperty CustomFontProperty
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.
Identifies the CustomFontSize dependency property. This property specifies the size of the custom font.
public static RadProperty CustomFontSizeProperty
The default value is 12.0f. This property is used in conjunction with CustomFont.
Identifies the CustomFontStyle dependency property. This property specifies the style of the custom font.
public static RadProperty CustomFontStyleProperty
The default value is FontStyle.Regular. This property is used in conjunction with CustomFont.
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.
public static RadProperty DefaultSizeProperty
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.
Identifies the Font dependency property. This property represents the font used for rendering text.
public static RadProperty FontProperty
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.
Identifies the ForeColor dependency property. This property represents the foreground color used for rendering text and borders.
public static RadProperty ForeColorProperty
This property can inherit its value from parent elements and affects the display of the element when changed.
Identifies the Opacity dependency property. This property determines the transparency level of the element.
public static RadProperty OpacityProperty
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.
Identifies the SmoothingMode dependency property. This property determines how graphics are smoothed when rendered.
public static RadProperty SmoothingModeProperty
Changes to this property affect the visual quality of rendered graphics. The default value is SmoothingMode.Default.
Properties
Gets or sets the background color of the element.
[TypeConverter(typeof(RadColorEditorConverter))]
public virtual Color BackColor { get; set; }
A Color that represents the background color of the element. The default value is determined by the current theme.
This property is inheritable through the element tree, allowing child elements to inherit the background color from their parents unless explicitly overridden.
Gets or sets the name of the custom font to be used for rendering text in this element.
[VsbBrowsable(true)]
[TypeConverter(typeof(CustomFontTypeConverter))]
public virtual string CustomFont { get; set; }
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".
Gets or sets the size of the custom font in points.
[VsbBrowsable(true)]
public virtual float CustomFontSize { get; set; }
This property is used when CustomFont is set to a value other than "None". The default size is 12 points.
Gets or sets the style for the custom font.
[VsbBrowsable(true)]
public virtual FontStyle CustomFontStyle { get; set; }
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.
Gets or sets the default size for the visual element.
public virtual Size DefaultSize { get; set; }
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.
Gets or sets the font used for rendering text in this element.
public virtual Font Font { get; set; }
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.
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.
Gets or sets the foreground color of the element.
[TypeConverter(typeof(RadColorEditorConverter))]
public virtual Color ForeColor { get; set; }
A Color that represents the foreground color used for text and borders. The default value is determined by the current theme.
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.
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).
public virtual double Opacity { get; set; }
Gets or sets the smoothing mode of an element. Smoothing mode enumeration defines possible values.
public virtual SmoothingMode SmoothingMode { get; set; }
Methods
Creates a scaled version of the specified font based on the provided scale factor.
Creates a scaled version of the element's font based on the provided scale factor.
public virtual Font GetScaledFont(float scale)
The scale factor to apply to the font.
Returns:A new Font object with size adjusted according to the scale factor.
This method applies DPI scaling if enabled. It's useful when rendering text at different zoom levels or on displays with different pixel densities.
Raises the FontChanged event.
Called when a property value has changed, allowing for custom response to property changes.
protected override void OnPropertyChanged(RadPropertyChangedEventArgs e)
The property changed event arguments.
Overrides:
Called before a property value is changed, allowing for validation or cancellation.
protected override void OnPropertyChanging(RadPropertyChangingEventArgs args)
The property changing event arguments.
Overrides:
Paints the child elements of this visual element with opacity support.
protected override void PaintChildren(IGraphics graphics, Rectangle clipRectangle, float angle, SizeF scale, bool useRelativeTransformation)
The graphics object used for painting.
clipRectangleRectangleThe clipping rectangle that limits the painting area.
anglefloatThe rotation angle to apply during painting.
scaleSizeFThe scale factor to apply during painting.
useRelativeTransformationboolTrue to use relative transformation; otherwise, false.
Overrides:
Paints the element's background and calls the base implementation to paint child elements.
Performs post-painting cleanup operations including restoring smoothing mode and opacity.
protected override void PostPaintElement(IGraphics graphics)
The graphics object used for painting.
Overrides:
Performs pre-painting operations including setting smoothing mode and opacity.
protected override void PrePaintElement(IGraphics graphics)
The graphics object used for painting.
Overrides:
Events
Occurs when the Font property value changes.
public event EventHandler FontChanged