Frame Class

Représente un contrôle de contenu qui prend en charge la navigation.

Héritage

Object
  DependencyObject
    UIElement
      FrameworkElement
        Control
          ContentControl
            Frame

Syntaxe


public class Frame : ContentControl,
    INavigate

Attributs

MarshalingBehaviorAttribute(Agile)
StaticAttribute(Windows.UI.Xaml.Controls.IFrameStatics, NTDDI_WIN8)
ThreadingAttribute(Both)
VersionAttribute(NTDDI_WIN8)
WebHostHiddenAttribute()

Membres

FrameClasse comporte les types de membres suivants :

Constructeurs

FrameClasse comporte les constructeurs suivants.

ConstructeurDescription
Frame Initializes a new instance of the Frame class.

 

Événements

FrameClasse comporte les événements suivants.

ÉvénementDescription
DoubleTapped Occurs when an otherwise unhandled DoubleTap interaction occurs over the hit test area of this element. (Hérité de UIElement)
DragEnter Occurs when the input system reports an underlying drag event with this element as the target. (Hérité de UIElement)
DragLeave Occurs when the input system reports an underlying drag event with this element as the origin. (Hérité de UIElement)
DragOver Occurs when the input system reports an underlying drag event with this element as the potential drop target. (Hérité de UIElement)
Drop Occurs when the input system reports an underlying drop event with this element as the drop target. (Hérité de UIElement)
GotFocus Occurs when a UIElement receives focus. (Hérité de UIElement)
Holding Occurs when an otherwise unhandled Hold interaction occurs over the hit test area of this element. (Hérité de UIElement)
IsEnabledChanged Occurs when the IsEnabled property changes. (Hérité de Control)
KeyDown Occurs when a keyboard key is pressed while the UIElement has focus. (Hérité de UIElement)
KeyUp Occurs when a keyboard key is released while the UIElement has focus. (Hérité de UIElement)
LayoutUpdated Occurs when the layout of the visual tree changes. (Hérité de FrameworkElement)
Loaded Occurs when a FrameworkElement has been constructed and added to the object tree, and is ready for interaction. (Hérité de FrameworkElement)
LostFocus Occurs when a UIElement loses focus. (Hérité de UIElement)
ManipulationCompleted Occurs when a manipulation on the UIElement is complete. (Hérité de UIElement)
ManipulationDelta Occurs when the input device changes position during a manipulation. (Hérité de UIElement)
ManipulationInertiaStarting Occurs when the input device loses contact with the UIElement object during a manipulation and inertia begins. (Hérité de UIElement)
ManipulationStarted Occurs when an input device begins a manipulation on the UIElement. (Hérité de UIElement)
ManipulationStarting Occurs when the manipulation processor is first created. (Hérité de UIElement)
Navigated Occurs when the content that is being navigated to has been found and is available from the Content property, although it may not have completed loading.
Navigating Occurs when a new navigation is requested.
NavigationFailed Occurs when an error is raised while navigating to the requested content.
NavigationStopped Occurs when a new navigation is requested while a current navigation is in progress.
PointerCanceled Occurs when a pointer that made contact abnormally loses contact. (Hérité de UIElement)
PointerCaptureLost Occurs when pointer capture previously held by this element moves to another element or elsewhere. (Hérité de UIElement)
PointerEntered Occurs when a pointer enters the hit test area of this element. (Hérité de UIElement)
PointerExited Occurs when a pointer leaves the hit test area of this element. (Hérité de UIElement)
PointerMoved Occurs when a pointer moves while the pointer remains within the hit test area of this element. (Hérité de UIElement)
PointerPressed Occurs when the pointer device initiates a Press action within this element. (Hérité de UIElement)
PointerReleased Occurs when the pointer device that previously initiated a Press action is released, while within this element. (Hérité de UIElement)
PointerWheelChanged Occurs when the delta value of a pointer wheel changes. (Hérité de UIElement)
RightTapped Occurs when a right-tap input stimulus happens while the pointer is over the element. (Hérité de UIElement)
SizeChanged Occurs when either the ActualHeight or the ActualWidth property changes value on a FrameworkElement. (Hérité de FrameworkElement)
Tapped Occurs when an otherwise unhandled Tap interaction occurs over the hit test area of this element. (Hérité de UIElement)
Unloaded Occurs when this object is no longer connected to the main object tree. (Hérité de FrameworkElement)

 

Méthodes

The Frame Classe comporte les méthodes suivantes. Il hérite également des méthodes de Object Classe.

MéthodeDescription
AddHandler Adds a routed event handler for a specified routed event, adding the handler to the handler collection on the current element. Specify handledEventsToo as true to have the provided handler be invoked even if the event is handled elsewhere. (Hérité de UIElement)
ApplyTemplate Loads the relevant control template so that its parts can be referenced. (Hérité de Control)
Arrange Positions child objects and determines a size for a UIElement. Parent objects that implement custom layout for their child elements should call this method from their layout override implementations to form a recursive layout update. (Hérité de UIElement)
ArrangeOverride Provides the behavior for the Arrange pass of layout. Classes can override this method to define their own Arrange pass behavior. (Hérité de FrameworkElement)
CapturePointer Sets pointer capture to a UIElement. Once captured, only the element that has capture will fire pointer-related events. (Hérité de UIElement)
ClearValue Clears the local value of a dependency property. (Hérité de DependencyObject)
FindName Retrieves an object that has the specified identifier name. (Hérité de FrameworkElement)
FindSubElementsForTouchTargeting Enables a UIElement subclass to expose child elements that assist with resolving touch targeting. (Hérité de UIElement)
Focus Attempts to set the focus on the control. (Hérité de Control)
GetAnimationBaseValue Returns any base value established for a dependency property, which would apply in cases where an animation is not active. (Hérité de DependencyObject)
GetNavigationState Serializes the Frame navigation history into a string.
GetTemplateChild Retrieves the named element in the instantiated ControlTemplate visual tree. (Hérité de Control)
GetValue Returns the current effective value of a dependency property from a DependencyObject. (Hérité de DependencyObject)
GoBack Navigates to the most recent item in back navigation history, if a Frame manages its own navigation history.
GoForward Navigates to the most recent item in forward navigation history, if a Frame manages its own navigation history.
InvalidateArrange Invalidates the arrange state (layout) for a UIElement. After the invalidation, the UIElement will have its layout updated, which will occur asynchronously. (Hérité de UIElement)
InvalidateMeasure Invalidates the measurement state (layout) for a UIElement. (Hérité de UIElement)
Measure Updates the DesiredSize of a UIElement. Typically, objects that implement custom layout for their layout children call this method from their own MeasureOverride implementations to form a recursive layout update. (Hérité de UIElement)
MeasureOverride Provides the behavior for the Measure pass of the layout cycle. Classes can override this method to define their own Measure pass behavior. (Hérité de FrameworkElement)
Navigate(TypeName) Causes the Frame to load content represented by the specified Page-derived data type.
Navigate(TypeName, Object) Causes the Frame to load content represented by the specified Page-derived data type, also passing a parameter to be interpreted by the target of the navigation.
OnApplyTemplate Invoked whenever application code or internal processes (such as a rebuilding layout pass) call ApplyTemplate. In simplest terms, this means the method is called just before a UI element displays in your app. Override this method to influence the default post-template logic of a class. (Hérité de FrameworkElement)
OnContentChanged Invoked when the value of the Content property changes. (Hérité de ContentControl)
OnContentTemplateChanged Invoked when the value of the ContentTemplate property changes. (Hérité de ContentControl)
OnContentTemplateSelectorChanged Invoked when the value of the ContentTemplateSelector property changes. (Hérité de ContentControl)
OnCreateAutomationPeer When implemented in a derived class, returns class-specific AutomationPeer implementations for the Microsoft UI Automation infrastructure. (Hérité de UIElement)
OnDisconnectVisualChildren Override this method to implement how layout and logic should behave when items are removed from a class-specific content or children property. (Hérité de UIElement)
OnDoubleTapped Called before the DoubleTapped event occurs. (Hérité de Control)
OnDragEnter Called before the DragEnter event occurs. (Hérité de Control)
OnDragLeave Called before the DragLeave event occurs. (Hérité de Control)
OnDragOver Called before the DragOver event occurs. (Hérité de Control)
OnDrop Called before the Drop event occurs. (Hérité de Control)
OnGotFocus Called before the GotFocus event occurs. (Hérité de Control)
OnHolding Called before the Holding event occurs. (Hérité de Control)
OnKeyDown Called before the KeyDown event occurs. (Hérité de Control)
OnKeyUp Called before the KeyUp event occurs. (Hérité de Control)
OnLostFocus Called before the LostFocus event occurs. (Hérité de Control)
OnManipulationCompleted Called before the ManipulationCompleted event occurs. (Hérité de Control)
OnManipulationDelta Called before the ManipulationDelta event occurs. (Hérité de Control)
OnManipulationInertiaStarting Called before the ManipulationInertiaStarting event occurs. (Hérité de Control)
OnManipulationStarted Called before the ManipulationStarted event occurs. (Hérité de Control)
OnManipulationStarting Called before the ManipulationStarting event occurs. (Hérité de Control)
OnPointerCanceled Called before the PointerCanceled event occurs. (Hérité de Control)
OnPointerCaptureLost Called before the PointerCaptureLost event occurs. (Hérité de Control)
OnPointerEntered Called before the PointerEntered event occurs. (Hérité de Control)
OnPointerExited Called before the PointerExited event occurs. (Hérité de Control)
OnPointerMoved Called before the PointerMoved event occurs. (Hérité de Control)
OnPointerPressed Called before the PointerPressed event occurs. (Hérité de Control)
OnPointerReleased Called before the PointerReleased event occurs. (Hérité de Control)
OnPointerWheelChanged Called before the PointerWheelChanged event occurs. (Hérité de Control)
OnRightTapped Called before the RightTapped event occurs. (Hérité de Control)
OnTapped Called before the Tapped event occurs. (Hérité de Control)
ReadLocalValue Returns the local value of a dependency property, if a local value is set. (Hérité de DependencyObject)
ReleasePointerCapture Releases pointer captures for capture of one specific pointer by this UIElement. (Hérité de UIElement)
ReleasePointerCaptures Releases all pointer captures held by this element. (Hérité de UIElement)
RemoveHandler Removes the specified routed event handler from this UIElement. Typically the handler in question was added by AddHandler. (Hérité de UIElement)
SetBinding Attaches a binding to a FrameworkElement, using the provided binding object. (Hérité de FrameworkElement)
SetNavigationState Reads and restores the navigation history of a Frame from a provided serialization string.
SetValue Sets the local value of a dependency property on a DependencyObject. (Hérité de DependencyObject)
TransformToVisual Returns a transform object that can be used to transform coordinates from the UIElement to the specified object. (Hérité de UIElement)
UpdateLayout Ensures that all positions of child objects of a UIElement are properly updated for layout. (Hérité de UIElement)

 

Propriétés

Le FrameClasse contient les propriétés suivantes.

PropriétéType d’accèsDescription

ActualHeight

en lecture seuleGets the rendered height of a FrameworkElement. (Hérité de FrameworkElement)

ActualWidth

en lecture seuleGets the rendered width of a FrameworkElement. (Hérité de FrameworkElement)

AllowDrop

en lecture/écritureGets or sets a value that determines whether this UIElement can be a drop target for purposes of drag-and-drop operations. (Hérité de UIElement)

Background

en lecture/écritureGets or sets a brush that provides the background of the control. (Hérité de Control)

BackStackDepth

en lecture seuleGets the number of entries in the navigation back stack.

BackStackDepthProperty

en lecture seuleIdentifies the BackStackDepth dependency property.

BaseUri

en lecture seuleGets a Uniform Resource Identifier (URI) that represents the base Uniform Resource Identifier (URI) for an XAML-constructed object at XAML load time. This property is useful for Uniform Resource Identifier (URI) resolution at run time. (Hérité de FrameworkElement)

BorderBrush

en lecture/écritureGets or sets a brush that describes the border background of a control. (Hérité de Control)

BorderThickness

en lecture/écritureGets or sets the border thickness of a control. (Hérité de Control)

CacheMode

en lecture/écritureGets or sets a value that indicates that rendered content should be cached as a composited bitmap when possible. (Hérité de UIElement)

CacheSize

en lecture/écritureGets or sets the number of pages in the navigation history that can be cached for the frame.

CacheSizeProperty

en lecture seuleIdentifies the CacheSize dependency property.

CanGoBack

en lecture seuleGets a value that indicates whether there is at least one entry in back navigation history.

CanGoBackProperty

en lecture seuleIdentifies the CanGoBack dependency property.

CanGoForward

en lecture seuleGets a value that indicates whether there is at least one entry in forward navigation history.

CanGoForwardProperty

en lecture seuleIdentifies the CanGoForward dependency property.

CharacterSpacing

en lecture/écritureGets or sets the uniform spacing between characters, in units of 1/1000 of an em. (Hérité de Control)

Clip

en lecture/écritureGets or sets the RectangleGeometry used to define the outline of the contents of a UIElement. (Hérité de UIElement)

Content

en lecture/écritureGets or sets the content of a ContentControl. (Hérité de ContentControl)

ContentTemplate

en lecture/écritureGets or sets the data template that is used to display the content of the ContentControl. (Hérité de ContentControl)

ContentTemplateSelector

en lecture/écritureGets or sets a selection object that changes the DataTemplate to apply for content, based on processing information about the content item or its container at run time. (Hérité de ContentControl)

ContentTransitions

en lecture/écritureGets or sets the collection of Transition style elements that apply to the content of a ContentControl. (Hérité de ContentControl)

CurrentSourcePageType

en lecture seuleGets the data type of the content that is currently displayed.

CurrentSourcePageTypeProperty

en lecture seuleIdentifies the CurrentSourcePageType dependency property.

DataContext

en lecture/écritureGets or sets the data context for a FrameworkElement when it participates in data binding. (Hérité de FrameworkElement)

DefaultStyleKey

en lecture/écritureGets or sets the key that references the default style for the control. (Hérité de Control)

DesiredSize

en lecture seuleGets the size that this UIElement computed during the measure pass of the layout process. (Hérité de UIElement)

Dispatcher

en lecture seuleGets the CoreDispatcher that this object is associated with. (Hérité de DependencyObject)

FlowDirection

en lecture/écritureGets or sets the direction in which text and other UI elements flow within any parent element that controls their layout. This property can be set to either LeftToRight or RightToLeft. Setting FlowDirection to RightToLeft on any element sets the alignment to the right, the reading order to right-to-left and the layout of the control to flow from right to left. (Hérité de FrameworkElement)

FocusState

en lecture seuleGets a value that specifies whether this control has focus, and the mode by which focus was obtained. (Hérité de Control)

FontFamily

en lecture/écritureGets or sets the font used to display text in the control. (Hérité de Control)

FontSize

en lecture/écritureGets or sets the size of the text in this control. (Hérité de Control)

FontStretch

en lecture/écritureGets or sets the degree to which a font is condensed or expanded on the screen. (Hérité de Control)

FontStyle

en lecture/écritureGets or sets the style in which the text is rendered. (Hérité de Control)

FontWeight

en lecture/écritureGets or sets the thickness of the specified font. (Hérité de Control)

Foreground

en lecture/écritureGets or sets a brush that describes the foreground color. (Hérité de Control)

Height

en lecture/écritureGets or sets the suggested height of a FrameworkElement. (Hérité de FrameworkElement)

HorizontalAlignment

en lecture/écritureGets or sets the horizontal alignment characteristics that are applied to a FrameworkElement when it is composed in a layout parent, such as a panel or items control. (Hérité de FrameworkElement)

HorizontalContentAlignment

en lecture/écritureGets or sets the horizontal alignment of the control's content. (Hérité de Control)

IsDoubleTapEnabled

en lecture/écritureGets or sets a value that determines whether the DoubleTapped event can originate from that element. (Hérité de UIElement)

IsEnabled

en lecture/écritureGets or sets a value indicating whether the user can interact with the control. (Hérité de Control)

IsHitTestVisible

en lecture/écritureGets or sets whether the contained area of this UIElement can return true values for hit testing. (Hérité de UIElement)

IsHoldingEnabled

en lecture/écritureGets or sets a value that determines whether the Holding event can originate from that element. (Hérité de UIElement)

IsRightTapEnabled

en lecture/écritureGets or sets a value that determines whether the RightTapped event can originate from that element. (Hérité de UIElement)

IsTabStop

en lecture/écritureGets or sets a value that indicates whether a control is included in tab navigation. (Hérité de Control)

IsTapEnabled

en lecture/écritureGets or sets a value that determines whether the Tapped event can originate from that element. (Hérité de UIElement)

Language

en lecture/écritureGets or sets localization/globalization language information that applies to a FrameworkElement, and also to all child elements of the current FrameworkElement in the object representation and in UI. (Hérité de FrameworkElement)

ManipulationMode

en lecture/écritureGets or sets the ManipulationModes value used for UIElement behavior and interaction with gestures. (Hérité de UIElement)

Margin

en lecture/écritureGets or sets the outer margin of a FrameworkElement. (Hérité de FrameworkElement)

MaxHeight

en lecture/écritureGets or sets the maximum height constraint of a FrameworkElement. (Hérité de FrameworkElement)

MaxWidth

en lecture/écritureGets or sets the maximum width constraint of a FrameworkElement. (Hérité de FrameworkElement)

MinHeight

en lecture/écritureGets or sets the minimum height constraint of a FrameworkElement. (Hérité de FrameworkElement)

MinWidth

en lecture/écritureGets or sets the minimum width constraint of a FrameworkElement. (Hérité de FrameworkElement)

Name

en lecture/écritureGets or sets the identifying name of the object. When a XAML processor creates the object tree from XAML markup, run-time code can refer to the XAML-declared object by this name. (Hérité de FrameworkElement)

Opacity

en lecture/écritureGets or sets the degree of the object's opacity. (Hérité de UIElement)

Padding

en lecture/écritureGets or sets the padding inside a control. (Hérité de Control)

Parent

en lecture seuleGets the parent object of this FrameworkElement in the object tree. (Hérité de FrameworkElement)

PointerCaptures

en lecture seuleGets the set of all captured pointers, represented as Pointer values. (Hérité de UIElement)

Projection

en lecture/écritureGets or sets the perspective projection (3-D effect) to apply when rendering this element. (Hérité de UIElement)

RenderSize

en lecture seuleGets the final render size of a UIElement. (Hérité de UIElement)

RenderTransform

en lecture/écritureGets or sets transform information that affects the rendering position of a UIElement. (Hérité de UIElement)

RenderTransformOrigin

en lecture/écritureGets or sets the origin point of any possible render transform declared by RenderTransform, relative to the bounds of the UIElement. (Hérité de UIElement)

Resources

en lecture/écritureGets the locally defined resource dictionary. In XAML, you can establish resource items as child object elements of a frameworkElement.Resources property element, through XAML implicit collection syntax. (Hérité de FrameworkElement)

SourcePageType

en lecture/écritureGets or sets the data type of the current content, or the content that should be navigated to.

SourcePageTypeProperty

en lecture seuleIdentifies the SourcePageType dependency property.

Style

en lecture/écritureGets or sets an instance Style that is applied for this object during layout and rendering. (Hérité de FrameworkElement)

TabIndex

en lecture/écritureGets or sets a value that determines the order in which elements receive focus when the user navigates through controls by pressing the Tab key. (Hérité de Control)

TabNavigation

en lecture/écritureGets or sets a value that modifies how tabbing and TabIndex work for this control. (Hérité de Control)

Tag

en lecture/écritureGets or sets an arbitrary object value that can be used to store custom information about this object. (Hérité de FrameworkElement)

Template

en lecture/écritureGets or sets a control template. The control template defines the visual appearance of a control in UI, and is defined in XAML markup. (Hérité de Control)

Transitions

en lecture/écritureGets or sets the collection of Transition style elements that apply to a UIElement. (Hérité de UIElement)

Triggers

en lecture seuleGets the collection of triggers for animations that are defined for a FrameworkElement. Not commonly used. (Hérité de FrameworkElement)

UseLayoutRounding

en lecture/écritureGets or sets a value that determines whether rendering for the object and its visual subtree should use rounding behavior that aligns rendering to whole pixels. (Hérité de UIElement)

VerticalAlignment

en lecture/écritureGets or sets the vertical alignment characteristics that are applied to a FrameworkElement when it is composed in a parent object such as a panel or items control. (Hérité de FrameworkElement)

VerticalContentAlignment

en lecture/écritureGets or sets the vertical alignment of the control's content. (Hérité de Control)

Visibility

en lecture/écritureGets or sets the visibility of a UIElement. A UIElement that is not visible is not rendered and does not communicate its desired size to layout. (Hérité de UIElement)

Width

en lecture/écritureGets or sets the width of a FrameworkElement. (Hérité de FrameworkElement)

 

Remarques

Utilisez le contrôle Frame pour prendre en charge la navigation vers les contrôles Page. Vous pouvez créer autant de pages différentes que nécessaire pour présenter le contenu dans votre application et naviguer ensuite vers ces pages à partir du frame. Pour naviguer à partir du frame, vous devez appeler la méthode Navigate et transmettre le type de la page à laquelle accéder. Vous pouvez également passer un objet paramètre pour initialiser la page à un état particulier.

L'image prend en charge la navigation vers l'avant et vers l'arrière dans l'historique de navigation. La navigation avant et arrière permet aux utilisateurs de naviguer facilement d'une page précédemment consultée à une autre et d'un état précédemment consulté d'une page à un autre. Vous utilisez les méthodes GoBack et GoForward pour lancer des demandes de navigation avant et arrière. Les propriétés CanGoBack et CanGoForward indiquent si une page est disponible dans la direction voulue. Une pratique courante consiste à lier les propriétés IsEnabled des boutons de navigation à CanGoBack et à CanGoForward afin que les utilisateurs ne puissent pas accéder à une page inexistante.

De nombreuses applications permettent aux utilisateurs d'accéder plusieurs fois aux mêmes pages. Frame comprend un cache de page pour plus d'efficacité. Vous définissez la propriété CacheSize pour spécifier le nombre de pages conservées dans le cache. Lorsqu'une page est mise en cache, une instance de cette page est réutilisée pour chaque requête de navigation. La page n'est ainsi pas recréée pour chaque requête.

Utilisez la propriété Page.NavigationCacheMode pour spécifier s'il faut réutiliser ou recréer les instances des types particuliers de pages en y accédant plusieurs fois.

Pour mettre en cache une page, vous devez définir la propriété Page.NavigationCacheMode sur Enabled ou Required. Lorsque la propriété NavigationCacheMode d'une page a la valeur Required, la page est mise en cache indépendamment du nombre de pages en cache spécifiées dans la propriété CacheSize. Les pages marquées comme Required ne sont pas décomptées du total CacheSize.

Exemples

L'exemple de code suivant montre la substitution de méthode OnLaunched générée pour le modèle d'application vierge dans Microsoft Visual Studio. Ce code montre comment le contenu de la fenêtre d'application est défini sur un nouveau Frame, qui est ensuite parcouru jusqu'au Pageinitial par défaut.


protected override void OnLaunched(LaunchActivatedEventArgs args)
{
    // Create a Frame to act navigation context and navigate to the first page
    var rootFrame = new Frame();
    rootFrame.Navigate(typeof(BlankPage));

    // Place the frame in the current Window and ensure that it is active
    Window.Current.Content = rootFrame;
    Window.Current.Activate();
}


Configuration requise

Client minimal pris en charge

Windows 8 [Applications du Windows Store uniquement]

Serveur minimal pris en charge

Windows Server 2012 [Applications du Windows Store uniquement]

Espace de noms

Windows.UI.Xaml.Controls
Windows::UI::Xaml::Controls [C++]

Métadonnées

Windows.winmd

Voir aussi

ContentControl
INavigate
Démarrage rapide : navigation entre les pages

 

 

Afficher:
© 2015 Microsoft