Class Control
Represents the base class for UI elements that use a ControlTemplate to define their appearance.
Inheritance
Inherited Members
Namespace: System.Windows.Controls
Assembly: OpenSilver.dll
Syntax
public class Control : FrameworkElement, IControl, IFrameworkElement, IUIElement, IDependencyObject
Constructors
| Improve this Doc View SourceControl()
Represents the base class for UI elements that use a ControlTemplate to define their appearance.
Declaration
public Control()
Fields
| Improve this Doc View SourceBackgroundProperty
Identifies the Background dependency property.
Declaration
public static readonly DependencyProperty BackgroundProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
BorderBrushProperty
Identifies the BorderBrush dependency property.
Declaration
public static readonly DependencyProperty BorderBrushProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
BorderThicknessProperty
Identifies the BorderThickness dependency property.
Declaration
public static readonly DependencyProperty BorderThicknessProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
CharacterSpacingProperty
Identifies the CharacterSpacing dependency property.
Declaration
public static readonly DependencyProperty CharacterSpacingProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
FontFamilyProperty
Identifies the FontFamily dependency property.
Declaration
public static readonly DependencyProperty FontFamilyProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
FontSizeProperty
Identifies the FontSize dependency property.
Declaration
public static readonly DependencyProperty FontSizeProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
FontStretchProperty
Identifies the FontStretch dependency property.
Declaration
[NotImplemented]
public static readonly DependencyProperty FontStretchProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
FontStyleProperty
Identifies the FontStyle dependency property.
Declaration
public static readonly DependencyProperty FontStyleProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
FontWeightProperty
Identifies the FontWeight dependency property.
Declaration
public static readonly DependencyProperty FontWeightProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
ForegroundProperty
Identifies the Foreground dependency property.
Declaration
public static readonly DependencyProperty ForegroundProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
HorizontalContentAlignmentProperty
Identifies the HorizontalContentAlignment dependency property.
Declaration
public static readonly DependencyProperty HorizontalContentAlignmentProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
IsTabStopProperty
Identifies the IsTabStop dependency property.
Declaration
public static readonly DependencyProperty IsTabStopProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
PaddingProperty
Identifies the Padding dependency property.
Declaration
public static readonly DependencyProperty PaddingProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
TabIndexProperty
Identifies the TabIndex dependency property.
Declaration
public static readonly DependencyProperty TabIndexProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
TabNavigationProperty
Identifies the TabNavigation dependency property.
Declaration
public static readonly DependencyProperty TabNavigationProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
TemplateProperty
Identifies the Template dependency property.
Declaration
public static readonly DependencyProperty TemplateProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
TextDecorationsProperty
Identifies the TextDecorations dependency property.
Declaration
public static readonly DependencyProperty TextDecorationsProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
VerticalContentAlignmentProperty
Identifies the VerticalContentAlignment dependency property.
Declaration
public static readonly DependencyProperty VerticalContentAlignmentProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
Properties
| Improve this Doc View SourceBackground
Gets or sets a brush that provides the background of the control.
Declaration
public Brush Background { get; set; }
Property Value
Type | Description |
---|---|
Brush |
BorderBrush
Gets or sets a brush that describes the border background of a control.
Declaration
public Brush BorderBrush { get; set; }
Property Value
Type | Description |
---|---|
Brush |
BorderThickness
Gets or sets the thickness of the border.
Declaration
public Thickness BorderThickness { get; set; }
Property Value
Type | Description |
---|---|
Thickness |
CharacterSpacing
Gets or sets the distance between characters of text in the control measured in 1000ths of the font size.
Declaration
public int CharacterSpacing { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 | The distance between characters of text in the control measured in 1000ths of the font size. The default is 0. |
EnableBaseControlHandlingOfVisualStates
Derived classes can set this flag to True in their constructor in order to disable the "GoToState" calls of this class related to PointerOver/Pressed/Disabled, and handle them by themselves. An example is the ToggleButton control, which contains states such as "CheckedPressed", "CheckedPointerOver", etc. The default value is false.
Declaration
protected bool EnableBaseControlHandlingOfVisualStates { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
FontFamily
Gets or sets the font used to display text in the control.
Declaration
public FontFamily FontFamily { get; set; }
Property Value
Type | Description |
---|---|
FontFamily |
FontSize
Gets or sets the size of the text in this control.
Declaration
public double FontSize { get; set; }
Property Value
Type | Description |
---|---|
System.Double | The size of the text in the Control. The default is 11 (in pixels). |
FontStretch
Gets or sets the degree to which a font is condensed or expanded on the screen.
Declaration
[NotImplemented]
public FontStretch FontStretch { get; set; }
Property Value
Type | Description |
---|---|
FontStretch | One of the values that specifies the degree to which a font is condensed or expanded on the screen. The default is Normal. |
FontStyle
Gets or sets the style in which the text is rendered.
Declaration
public FontStyle FontStyle { get; set; }
Property Value
Type | Description |
---|---|
FontStyle |
FontWeight
Gets or sets the thickness of the specified font.
Declaration
public FontWeight FontWeight { get; set; }
Property Value
Type | Description |
---|---|
FontWeight |
Foreground
Gets or sets a brush that describes the foreground color.
Declaration
public Brush Foreground { get; set; }
Property Value
Type | Description |
---|---|
Brush | The brush that paints the foreground of the control. The default value is Black. |
HandlesScrolling
Gets a value that indicates whether a control supports scrolling.
Declaration
protected virtual bool HandlesScrolling { get; }
Property Value
Type | Description |
---|---|
System.Boolean | true if the control has a ScrollViewer in its style and has a custom keyboard scrolling behavior; otherwise, false. |
HorizontalContentAlignment
Gets or sets the horizontal alignment of the control's content.
Declaration
public HorizontalAlignment HorizontalContentAlignment { get; set; }
Property Value
Type | Description |
---|---|
HorizontalAlignment |
IsTabStop
Gets or sets a value that indicates whether a control is included in tab navigation.
Declaration
public bool IsTabStop { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Padding
Gets or sets the distance between the border and its child object.
Declaration
public Thickness Padding { get; set; }
Property Value
Type | Description |
---|---|
Thickness |
TabIndex
Gets or sets a value that determines the order in which elements receive focus when the user navigates through controls by pressing the Tab key. The default value is MaxValue
Declaration
public int TabIndex { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
TabNavigation
Gets or sets a value that modifies how tabbing and TabIndex work for this control.
Declaration
public KeyboardNavigationMode TabNavigation { get; set; }
Property Value
Type | Description |
---|---|
KeyboardNavigationMode | A value of the enumeration. The default is Local. |
Template
Gets or sets a control template.
Declaration
public ControlTemplate Template { get; set; }
Property Value
Type | Description |
---|---|
ControlTemplate |
TextDecorations
Gets or sets the text decorations (underline, strikethrough...).
Declaration
public TextDecorationCollection TextDecorations { get; set; }
Property Value
Type | Description |
---|---|
TextDecorationCollection |
VerticalContentAlignment
Gets or sets the vertical alignment of the control's content.
Declaration
public VerticalAlignment VerticalContentAlignment { get; set; }
Property Value
Type | Description |
---|---|
VerticalAlignment |
Methods
| Improve this Doc View SourceApplyTemplate()
Loads the relevant control template so that its parts can be referenced.
Declaration
public bool ApplyTemplate()
Returns
Type | Description |
---|---|
System.Boolean | Returns whether the visual tree was rebuilt by this call. true indicates the tree was rebuilt; false indicates that the previous visual tree was retained. |
ArrangeOverride(Size)
Provides the behavior for the Arrange pass of Silverlight layout. Classes can override this method to define their own Arrange pass behavior.
Declaration
protected override Size ArrangeOverride(Size finalSize)
Parameters
Type | Name | Description |
---|---|---|
Size | finalSize | The final area within the parent that this object should use to arrange itself and its children. |
Returns
Type | Description |
---|---|
Size | The actual size that is used after the element is arranged in layout. |
Overrides
| Improve this Doc View SourceCreateDomElement(Object, out Object)
Declaration
public sealed override object CreateDomElement(object parentRef, out object domElementWhereToPlaceChildren)
Parameters
Type | Name | Description |
---|---|---|
System.Object | parentRef | |
System.Object | domElementWhereToPlaceChildren |
Returns
Type | Description |
---|---|
System.Object |
Overrides
| Improve this Doc View SourceFocus()
Attempts to set the focus on the control.
Declaration
public bool Focus()
Returns
Type | Description |
---|---|
System.Boolean | true if focus was set to the control, or focus was already on the control. false if the control is not focusable. |
GetTemplateChild(String)
Retrieves the named element in the instantiated ControlTemplate visual tree.
Declaration
protected DependencyObject GetTemplateChild(string childName)
Parameters
Type | Name | Description |
---|---|---|
System.String | childName | The name of the element to find. |
Returns
Type | Description |
---|---|
DependencyObject | The named element from the template, if the element is found. Can return null if no element with name childName was found in the template. |
ManageIsEnabled(Boolean)
Declaration
protected override void ManageIsEnabled(bool isEnabled)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | isEnabled |
Overrides
| Improve this Doc View SourceMeasureOverride(Size)
Provides the behavior for the Measure pass of Silverlight layout. Classes can override this method to define their own Measure pass behavior.
Declaration
protected override Size MeasureOverride(Size availableSize)
Parameters
Type | Name | Description |
---|---|---|
Size | availableSize | The available size that this object can give to child objects. Infinity (System.Double.PositiveInfinity) can be specified as a value to indicate that the object will size to whatever content is available. |
Returns
Type | Description |
---|---|
Size | The size that this object determines it needs during layout, based on its calculations of the allocated sizes for child objects; or based on other considerations, such as a fixed container size. |
Overrides
| Improve this Doc View SourceOnApplyTemplate()
Declaration
public override void OnApplyTemplate()
Overrides
| Improve this Doc View SourceOnDragEnter(DragEventArgs)
Declaration
[NotImplemented]
protected virtual void OnDragEnter(DragEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
DragEventArgs | e |
OnDragLeave(DragEventArgs)
Declaration
[NotImplemented]
protected virtual void OnDragLeave(DragEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
DragEventArgs | e |
OnDrop(DragEventArgs)
Declaration
[NotImplemented]
protected virtual void OnDrop(DragEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
DragEventArgs | e |
OnGotFocus(RoutedEventArgs)
Called before the GotFocus event occurs.
Declaration
protected override void OnGotFocus(RoutedEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
RoutedEventArgs | e | The data for the event. |
Overrides
| Improve this Doc View SourceOnLostFocus(RoutedEventArgs)
Called before the LostFocus event occurs.
Declaration
protected override void OnLostFocus(RoutedEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
RoutedEventArgs | e | The data for the event. |
Overrides
| Improve this Doc View SourceOnTextInputUpdate(TextCompositionEventArgs)
Declaration
[NotImplemented]
protected virtual void OnTextInputUpdate(TextCompositionEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
TextCompositionEventArgs | e |