Class TemplatedControl
- Namespace
- Avalonia.Controls.Primitives
- Assembly
- Avalonia.Controls.dll
A lookless control whose visual appearance is defined by its Template.
public class TemplatedControl : Control, INotifyPropertyChanged, IDataContextProvider, ILogical, IThemeVariantHost, IResourceHost, IResourceNode, IStyleHost, ISetLogicalParent, ISetInheritanceParent, ISupportInitialize, IStyleable, INamed, IInputElement, IDataTemplateHost, ISetterValue
- Inheritance
-
TemplatedControl
- Implements
- Derived
- Inherited Members
- Extension Methods
Constructors
TemplatedControl()
public TemplatedControl()
Fields
BackgroundProperty
Defines the Background property.
public static readonly StyledProperty<IBrush?> BackgroundProperty
Field Value
BackgroundSizingProperty
Defines the BackgroundSizing property.
public static readonly StyledProperty<BackgroundSizing> BackgroundSizingProperty
Field Value
BorderBrushProperty
Defines the BorderBrush property.
public static readonly StyledProperty<IBrush?> BorderBrushProperty
Field Value
BorderThicknessProperty
Defines the BorderThickness property.
public static readonly StyledProperty<Thickness> BorderThicknessProperty
Field Value
CornerRadiusProperty
Defines the CornerRadius property.
public static readonly StyledProperty<CornerRadius> CornerRadiusProperty
Field Value
FontFamilyProperty
Defines the FontFamily property.
public static readonly StyledProperty<FontFamily> FontFamilyProperty
Field Value
FontFeaturesProperty
Defines the FontFeaturesProperty property.
public static readonly StyledProperty<FontFeatureCollection?> FontFeaturesProperty
Field Value
FontSizeProperty
Defines the FontSize property.
public static readonly StyledProperty<double> FontSizeProperty
Field Value
FontStretchProperty
Defines the FontWeight property.
public static readonly StyledProperty<FontStretch> FontStretchProperty
Field Value
FontStyleProperty
Defines the FontStyle property.
public static readonly StyledProperty<FontStyle> FontStyleProperty
Field Value
FontWeightProperty
Defines the FontWeight property.
public static readonly StyledProperty<FontWeight> FontWeightProperty
Field Value
ForegroundProperty
Defines the Foreground property.
public static readonly StyledProperty<IBrush?> ForegroundProperty
Field Value
IsTemplateFocusTargetProperty
Defines the IsTemplateFocusTarget attached property.
public static readonly AttachedProperty<bool> IsTemplateFocusTargetProperty
Field Value
PaddingProperty
Defines the Padding property.
public static readonly StyledProperty<Thickness> PaddingProperty
Field Value
TemplateAppliedEvent
Defines the TemplateApplied routed event.
public static readonly RoutedEvent<TemplateAppliedEventArgs> TemplateAppliedEvent
Field Value
TemplateProperty
Defines the Template property.
public static readonly StyledProperty<IControlTemplate?> TemplateProperty
Field Value
Properties
Background
Gets or sets the brush used to draw the control's background.
public IBrush? Background { get; set; }
Property Value
BackgroundSizing
Gets or sets how the control's background is drawn relative to the control's border.
public BackgroundSizing BackgroundSizing { get; set; }
Property Value
BorderBrush
Gets or sets the brush used to draw the control's border.
public IBrush? BorderBrush { get; set; }
Property Value
BorderThickness
Gets or sets the thickness of the control's border.
public Thickness BorderThickness { get; set; }
Property Value
CornerRadius
Gets or sets the radius of the border rounded corners.
public CornerRadius CornerRadius { get; set; }
Property Value
FontFamily
Gets or sets the font family used to draw the control's text.
public FontFamily FontFamily { get; set; }
Property Value
FontFeatures
Gets or sets the font features turned on/off.
public FontFeatureCollection? FontFeatures { get; set; }
Property Value
FontSize
Gets or sets the size of the control's text in points.
public double FontSize { get; set; }
Property Value
FontStretch
Gets or sets the font stretch used to draw the control's text.
public FontStretch FontStretch { get; set; }
Property Value
FontStyle
Gets or sets the font style used to draw the control's text.
public FontStyle FontStyle { get; set; }
Property Value
FontWeight
Gets or sets the font weight used to draw the control's text.
public FontWeight FontWeight { get; set; }
Property Value
Foreground
Gets or sets the brush used to draw the control's text and other foreground elements.
public IBrush? Foreground { get; set; }
Property Value
Padding
Gets or sets the padding placed between the border of the control and its content.
public Thickness Padding { get; set; }
Property Value
Template
Gets or sets the template that defines the control's appearance.
public IControlTemplate? Template { get; set; }
Property Value
Methods
ApplyTemplate()
Creates the visual children of the control, if necessary
public override sealed void ApplyTemplate()
GetIsTemplateFocusTarget(Control)
Gets the value of the IsTemplateFocusTargetProperty attached property on a control.
public static bool GetIsTemplateFocusTarget(Control control)
Parameters
control
ControlThe control.
Returns
- bool
The property value.
GetTemplateFocusTarget()
Gets the element that receives the focus adorner.
protected override Control GetTemplateFocusTarget()
Returns
- Control
The control that receives the focus adorner.
OnApplyTemplate(TemplateAppliedEventArgs)
Called when the control's template is applied. In simple terms, this means the method is called just before the control is displayed.
protected virtual void OnApplyTemplate(TemplateAppliedEventArgs e)
Parameters
e
TemplateAppliedEventArgsThe event args.
OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs)
Called when the styled element is added to a rooted logical tree.
protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e)
Parameters
e
LogicalTreeAttachmentEventArgsThe event args.
OnDetachedFromLogicalTree(LogicalTreeAttachmentEventArgs)
Called when the styled element is removed from a rooted logical tree.
protected override void OnDetachedFromLogicalTree(LogicalTreeAttachmentEventArgs e)
Parameters
e
LogicalTreeAttachmentEventArgsThe event args.
OnTemplateChanged(AvaloniaPropertyChangedEventArgs)
Called when the Template property changes.
protected virtual void OnTemplateChanged(AvaloniaPropertyChangedEventArgs e)
Parameters
e
AvaloniaPropertyChangedEventArgsThe event args.
SetIsTemplateFocusTarget(Control, bool)
Sets the value of the IsTemplateFocusTargetProperty attached property on a control.
public static void SetIsTemplateFocusTarget(Control control, bool value)
Parameters
Remarks
When a control is navigated to using the keyboard, a focus adorner is shown - usually around the control itself. However if the TemplatedControl.IsTemplateFocusTarget attached property is set to true on an element in the control template, then the focus adorner will be shown around that control instead.
Events
TemplateApplied
Raised when the control's template is applied.
public event EventHandler<TemplateAppliedEventArgs>? TemplateApplied