UIControl Class |
Namespace: DigitalRune.Game.UI.Controls
The UIControl type exposes the following members.
Name | Description | |
---|---|---|
Arrange |
Positions child elements and determines a size for a control.
| |
BringIntoView |
Attempts to bring this element into view, within any scrollable regions it is contained
within.
| |
CreateEventT |
Creates a game object event for a UIControl. (This method replaces
CreateEventT(String, String, String, T) of the GameObject class.)
| |
CreatePropertyT |
Creates a game object property for a UIControl. (This method replaces
CreatePropertyT(String, String, String, T) of the GameObject class.)
| |
Equals | (Inherited from Object.) | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
Focus |
Moves the input focus to this control.
| |
GetControl |
Gets a control by name from the visual subtree of this control.
| |
GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) | |
GetPropertyOptions |
Gets the UIPropertyOptions of game object property.
| |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
GetValueT(Int32) |
Gets the value of the property with the given ID.
(Inherited from GameObject.) | |
GetValueT(String) |
Gets the value of the property with the given name.
(Inherited from GameObject.) | |
GetValueT(GamePropertyMetadataT) |
Gets the value of the property with the given metadata.
(Inherited from GameObject.) | |
HitTest |
Tests if a position is over a control.
| |
InvalidateArrange |
Invalidates the arrange state (layout) for the control.
| |
InvalidateMeasure |
Invalidates the measurement state (layout) for the control.
| |
InvalidateVisual |
Invalidates the cached RenderData.
| |
Load |
Loads the content of the game object.
(Inherited from GameObject.) | |
Measure |
Updates the DesiredWidth and DesiredHeight of the control.
| |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
NewFrame |
Tells the game object to prepare itself for the next time step.
(Inherited from GameObject.) | |
OnArrange |
Called by Arrange(Vector2F, Vector2F) to arrange the visual children.
| |
OnHandleInput |
Called when the control should handle device input.
| |
OnLoad |
Called when the game object should load its content.
(Overrides GameObjectOnLoad.) | |
OnMeasure |
Called by Measure(Vector2F) to compute the control-specific desired size.
| |
OnPropertyChanged(PropertyChangedEventArgs) |
Raises the PropertyChanged event.
(Inherited from GameObject.) | |
OnPropertyChangedT(GamePropertyT, T, T) |
Is called after a game object property was changed.
(Inherited from GameObject.) | |
OnPropertyChangedT(GamePropertyT, T, T) |
Is called after a game object property was changed.
(Overrides GameObjectOnPropertyChangedT(GamePropertyT, T, T).) | |
OnRender |
Called when the control and its visual children should be rendered.
| |
OnTemplateChanged |
Raises the TemplateChanged event.
(Inherited from GameObject.) | |
OnUnload |
Called when the game object should unload its content.
(Overrides GameObjectOnUnload.) | |
OnUpdate |
Called when the game object should be updated.
(Overrides GameObjectOnUpdate(TimeSpan).) | |
OverrideDefaultValueT |
Overrides the default value of a game object property for a specific class.
| |
Render |
Renders the control (including visual children).
| |
SetPropertyOptions |
Sets the UIPropertyOptions of a game object property.
| |
SetValueT(Int32, T) |
Sets the value of the property with the given ID.
(Inherited from GameObject.) | |
SetValueT(String, T) |
Sets the value of the property with the given name.
(Inherited from GameObject.) | |
SetValueT(GamePropertyMetadataT, T) |
Set the value of the property for the given metadata.
(Inherited from GameObject.) | |
ToString | Returns a string that represents the current object. (Inherited from Object.) | |
Unload |
Unloads the content of the game object.
(Inherited from GameObject.) | |
Update |
Updates this game object.
(Inherited from GameObject.) | |
UpdateLayout |
Ensures that all visual child controls of this element are properly updated for layout.
|
Name | Description | |
---|---|---|
GetAncestors |
Gets the ancestors of the control in the visual tree.
(Defined by UIHelper.) | |
GetDescendants | Overloaded.
Gets the descendants of the control in the visual tree using a depth-first search.
(Defined by UIHelper.) | |
GetDescendants(Boolean) | Overloaded.
Gets the descendants of the control in the visual tree using either a depth-first or a
breadth-first search.
(Defined by UIHelper.) | |
GetLeaves |
Gets the leaves of the control in the visual tree.
(Defined by UIHelper.) | |
GetRoot |
Returns the root control of the visual tree.
(Defined by UIHelper.) | |
GetSelfAndAncestors |
Gets the control and its ancestors in the visual tree.
(Defined by UIHelper.) | |
GetSubtree | Overloaded.
Gets the subtree (the given control and all of its descendants in the visual tree) using a
depth-first search.
(Defined by UIHelper.) | |
GetSubtree(Boolean) | Overloaded.
Gets the subtree (the given control and all of its descendants in the visual tree) using
either a depth-first or a breadth-first search.
(Defined by UIHelper.) |
Name | Description | |
---|---|---|
AutoUnfocusPropertyId |
The ID of the AutoUnfocus game object property.
| |
BackgroundPropertyId |
The ID of the Background game object property.
| |
FocusablePropertyId |
The ID of the Focusable game object property.
| |
FocusWhenMouseOverPropertyId |
The ID of the FocusWhenMouseOver game object property.
| |
FontPropertyId |
The ID of the Font game object property.
| |
ForegroundPropertyId |
The ID of the Foreground game object property.
| |
HeightPropertyId |
The ID of the Height game object property.
| |
HorizontalAlignmentPropertyId |
The ID of the HorizontalAlignment game object property.
| |
IsEnabledPropertyId |
The ID of the IsEnabled game object property.
| |
IsFocusedPropertyId |
The ID of the IsFocused game object property.
| |
IsFocusScopePropertyId |
The ID of the IsFocusScope game object property.
| |
IsMouseOverPropertyId |
The ID of the IsMouseOver game object property.
| |
IsVisiblePropertyId |
The ID of the IsVisible game object property.
| |
MarginPropertyId |
The ID of the Margin game object property.
| |
MaxHeightPropertyId |
The ID of the MaxHeight game object property.
| |
MaxWidthPropertyId |
The ID of the MaxWidth game object property.
| |
MinHeightPropertyId |
The ID of the MinHeight game object property.
| |
MinWidthPropertyId |
The ID of the MinWidth game object property.
| |
OpacityPropertyId |
The ID of the Opacity game object property.
| |
PaddingPropertyId |
The ID of the Padding game object property.
| |
RenderRotationPropertyId |
The ID of the RenderRotation game object property.
| |
RenderScalePropertyId |
The ID of the RenderScale game object property.
| |
RenderTransformOriginPropertyId |
The ID of the RenderTransformOrigin game object property.
| |
RenderTranslationPropertyId |
The ID of the RenderTranslation game object property.
| |
ToolTipPropertyId |
The ID of the ToolTip game object property.
| |
VerticalAlignmentPropertyId |
The ID of the VerticalAlignment game object property.
| |
WidthPropertyId |
The ID of the Width game object property.
| |
XPropertyId |
The ID of the X game object property.
| |
YPropertyId |
The ID of the Y game object property.
|
Name | Description | |
---|---|---|
ActualBounds |
Gets the actual bounding rectangle of the control (defined by ActualX,
ActualY, ActualWidth and ActualHeight).
| |
ActualHeight |
Gets the actual height of the control (computed in
Arrange(Vector2F, Vector2F)).
| |
ActualIsEnabled |
Gets a value indicating whether this control is actually enabled, taking into account the
IsEnabled flag and the state of the VisualParent.
| |
ActualIsVisible |
Gets a value indicating whether this control is actually visible, taking into account the
IsVisible flag and the state of the VisualParent.
| |
ActualWidth |
Gets the actual width of the control (computed in
Arrange(Vector2F, Vector2F)).
| |
ActualX |
Gets the actual X position of the top left corner of the control's bounds in screen
coordinates (computed in Arrange(Vector2F, Vector2F)).
| |
ActualY |
Gets the actual Y position of the top left corner of the control's bounds in screen
coordinates (computed in Arrange(Vector2F, Vector2F)).
| |
AllowedPlayer |
Gets or sets the LogicalPlayerIndex from which input is accepted.
| |
AutoUnfocus |
Gets or sets a value indicating whether this control clears the focus when the mouse clicks
another control than the currently focused control. This is a game object property.
| |
Background |
Gets or sets the background color.
This is a game object property.
| |
ContextMenu |
Gets or sets the context menu that should pop up when the control is right-clicked
(tap-and-hold on Windows Phone 7).
| |
Cursor |
Gets or sets the mouse cursor that should be displayed when the mouse is over this control.
| |
DesiredHeight |
Gets the desired height (including Margin) (which is computed in
Measure(Vector2F)).
| |
DesiredWidth |
Gets the desired width (including Margin) (which is computed in
Measure(Vector2F)).
| |
Events |
Gets the game object events.
(Inherited from GameObject.) | |
Focusable |
Gets or sets a value indicating whether this UIControl can receive the input
focus. This is a game object property.
| |
FocusWhenMouseOver |
Gets or sets a value indicating whether the control automatically receives focus when the
mouse is over the control (without being clicked). This is a game object property.
| |
Font |
Gets or sets the font that is used if the control renders text.
This is a game object property.
| |
Foreground |
Gets or sets the foreground color.
This is a game object property.
| |
HasRenderTransform |
Gets a value indicating whether this control has a render transform that is not the
identity transformation.
| |
Height |
Gets or sets the user-defined height.
This is a game object property.
| |
HorizontalAlignment |
Gets or sets the horizontal alignment of this control.
This is a game object property.
| |
InputService |
Gets the IInputService.
| |
IsArrangeValid |
Gets a value indicating whether the Arrange(Vector2F, Vector2F) results are
up-to-date.
| |
IsEnabled |
Gets or sets a value indicating whether this control is enabled.
This is a game object property.
| |
IsFocused |
Gets a value indicating whether this control has the input focus.
This is a game object property.
| |
IsFocusScope |
Gets or sets a value indicating whether this control is a focus scope.
This is a game object property.
| |
IsFocusWithin |
Gets (or sets) a value indicating whether the focus is on this control or on any of
the visual children.
| |
IsLoaded |
Gets a value indicating whether the content of this object was loaded.
(Inherited from GameObject.) | |
IsMeasureValid |
Gets a value indicating whether the Measure(Vector2F) results
(DesiredWidth and DesiredHeight) are up-to-date.
| |
IsMouseDirectlyOver |
Gets a value indicating whether the mouse is over this control and not over a visual child
control.
| |
IsMouseOver |
Gets or sets a value indicating whether the mouse is over this control or over a visual
child. This is a game object property.
| |
IsVisible |
Gets or sets a value indicating whether this control is visible.
This is a game object property.
| |
IsVisualValid |
Gets a value indicating whether the cached RenderData is up-to-date.
| |
Margin |
Gets or sets the margin.
This is a game object property.
| |
MaxHeight |
Gets or sets the maximal height of the control.
This is a game object property.
| |
MaxWidth |
Gets or sets the maximal width of the control.
This is a game object property.
| |
MinHeight |
Gets or sets the minimal height of the control.
This is a game object property.
| |
MinWidth |
Gets or sets the minimal width of the control.
This is a game object property.
| |
Name |
Gets or sets the name.
(Inherited from GameObject.) | |
Opacity |
Gets or sets the opacity.
This is a game object property.
| |
Padding |
Gets or sets the padding.
This is a game object property.
| |
Properties |
Gets the game object properties.
(Inherited from GameObject.) | |
RenderData |
Gets or sets the cached renderer data.
| |
RendererInfo | Obsolete.
Gets or sets the cached renderer data.
| |
RenderRotation |
Gets or sets the rotation of the RenderTransform.
This is a game object property.
| |
RenderScale |
Gets or sets the scale of the RenderTransform.
This is a game object property.
| |
RenderTransform |
Gets the render transformation.
| |
RenderTransformOrigin |
Gets or sets the relative origin of the RenderTransform.
This is a game object property.
| |
RenderTranslation |
Gets or sets the translation of the RenderTransform.
This is a game object property.
| |
Screen |
Gets the UIScreen.
| |
Style |
Gets or sets the style.
| |
Tag | Obsolete.
Gets or sets a user-defined tag.
| |
Template |
Gets or sets the template.
(Inherited from GameObject.) | |
ToolTip |
Gets or sets the tool tip.
This is a game object property.
| |
UIService |
Gets the IUIService.
| |
UserData |
Gets or sets user-defined data.
| |
VerticalAlignment |
Gets or sets the vertical alignment of this control.
This is a game object property.
| |
VisualChildren |
Gets the visual children.
| |
VisualParent |
Gets the visual parent.
| |
VisualState |
Gets the visual state of the control as string.
| |
Width |
Gets or sets the user-defined width.
This is a game object property.
| |
X | ||
Y |
Name | Description | |
---|---|---|
InputProcessed |
Occurs after the device input was processed.
| |
InputProcessing |
Occurs before the device input is processed.
| |
PropertyChanged |
Occurs when a property value has changed.
(Inherited from GameObject.) | |
TemplateChanged |
Occurs when the Template changed.
(Inherited from GameObject.) |
Name | Description | |
---|---|---|
INotifyPropertyChangedPropertyChanged |
Occurs when a property value has changed.
(Inherited from GameObject.) | |
IAnimatableObjectGetAnimatablePropertyT |
Gets the property with given name and type which can be animated.
(Inherited from GameObject.) | |
IAnimatableObjectGetAnimatedProperties |
Gets either the properties which are currently animated, or all properties which can be
animated. (See remarks.)
(Inherited from GameObject.) |
The Visual Tree: Controls are managed in a visual tree. Each control has a VisualParent and VisualChildren. VisualChildren are managed by the control classes themselves; this collection should not be directly changed by the user. The controls will automatically put a "logical child" into the VisualChildren collection if necessary. The root of the visual tree is the UIScreen which starts all update, layout and render traversals. The VisualParent of the UIScreen is . Only objects in the visual tree handle input, take part in the layout process and are rendered.
The Logical Tree: ContentControls have a Content property. Panels and the UIScreen have a Children property. Other controls may have an Items property. Using these properties the user can create parent-child relationships which define the logical tree.
A Logical/Visual Tree Example: A Window is a ContentControl, therefore it has a Content property. The user adds a logical child to the window by setting the Content property. The window will automatically put the Content into the VisualChildren collection because the Content should be updated and rendered with the window. The window has a few more visual children: An Image control that draws the window icon, a TextBlock that draws the window title and a Button that represents the Close button of a window. These "internal" controls are also visual children.
IsLoaded: The UIControl is loaded (IsLoaded) when the control is added to the VisualChildren of a loaded control, or when the control is in the VisualChildren of an unloaded parent control and the parent control is loaded. Update(TimeSpan) is automatically called if the control is loaded.
PropertyChanged Events: PropertyChanged events are only raised for game object properties, like Background, IsEnabled, etc. The event is not raised for "normal" properties, like ActualIsEnabled, Screen, VisualState, etc.
Render Transforms: Controls have a RenderTransform that is defined using the game object properties RenderTransformOrigin, RenderTranslation, RenderRotation and RenderScale. The render transform can be used to scale, rotate and translate the control. The render transform is correctly applied when input is handled (e.g. mouse clicks). But the render transform is ignored in the layout process.
UIControl Properties: A UIControl is derived from GameObject and therefore has game object properties (see GamePropertyT) and game object events (see GameEventT). One big advantage of the game object property system is that they can be initialized in the XML file of the UI Theme. The UI control properties are extended game object properties: They must be created using CreatePropertyT(Type, String, String, String, T, UIPropertyOptions) and CreateEventT(Type, String, String, String, T). UIPropertyOptions can be assigned to UI control properties (see GetPropertyOptions(Int32) and SetPropertyOptions(Int32, UIPropertyOptions)). Depending on the UIPropertyOptions property changes automatically invoke InvalidateMeasure, InvalidateArrange, or InvalidateVisual when required. Game object properties have only one global default value. If a control class, e.g. a Button, should have class-specific default values, the method OverrideDefaultValueT(Type, Int32, T) can be used.
Styles and Templates: Each control has a Style. When the control is loaded. The control retrieves style information (e.g. default values) from the IUIRenderer and creates a template game object with property values determined by the used Style. This game object is set as the Template. To apply a new style to an already loaded control, the control must first be removed from the visual tree and afterwards added back again to the visual tree.
The Layout Process: The layout process is a simplified version of the WPF/Silverlight layout process. The layout process starts at the root of the visual tree (the UIScreen) or when UpdateLayout is called. First, Measure(Vector2F) is called for all controls in the visual tree. Measure(Vector2F) computes the DesiredWidth and DesiredHeight of a control. These values are determined either by the theme or the user (see Width, Height, MinWidth and MinHeight) or automatically computed by the control. It is also possible to call Measure(Vector2F) manually.
After that, Arrange(Vector2F, Vector2F) is called for all controls in the visual tree. Arrange(Vector2F, Vector2F) computes the ActualX, ActualY, ActualWidth and ActualHeight of a control in screen coordinates. The actual bounds are determined by the properties X, Y, Margin, HorizontalAlignment and VerticalAlignment. (X and Y are usually only used for controls in a Canvas or directly under the UIScreen.) The measure and arrange results are cached, and the layout process is only repeated when necessary. A new layout process can be issued using InvalidateMeasure or InvalidateArrange. When game object properties are changed, they automatically invalidate the layout if necessary. Derived classes can override OnMeasure(Vector2F) and OnArrange(Vector2F, Vector2F) to customize the layout results.
The Rendering Process: The rendering process starts at the root of the visual tree (the screen) when Draw(TimeSpan) is called by the user. Render(UIRenderContext) will be called for each control in the visual tree. Derived classes can override OnRender(UIRenderContext) to do custom drawing. Per default, OnRender(UIRenderContext) lets the renderer draw the control (see Render(UIControl, UIRenderContext)).
Custom Rendering: There are several ways to customize the appearance and rendering of controls:
Visual States: The VisualStates of this control are: "Disabled", "Default"