Popup Class

Visualizza il contenuto all'inizio del contenuto esistente, all'interno dei limiti della finestra dell'applicazione.

Ereditarietà

Object
  DependencyObject
    UIElement
      FrameworkElement
        Popup

Sintassi


public sealed class Popup : FrameworkElement

Attributi

[ContentProperty("Name=Child")]
[MarshalingBehavior(Agile)]
[Threading(Both)]
[Version(0x06020000)]
[WebHostHidden()]

Membri

PopupClasse include questi tipi di membri:

Costruttori

PopupClasse include questi costruttori.

CostruttoreDescrizione
Popup Initializes a new instance of the Popup class.

 

Eventi

PopupClasse include questi eventi.

EventoDescrizione
Closed Fires when the IsOpen property is set to false.
DataContextChanged Occurs when the value of the FrameworkElement.DataContext property changes. (Ereditata da FrameworkElement)
DoubleTapped Occurs when an otherwise unhandled DoubleTap interaction occurs over the hit test area of this element. (Ereditata da UIElement)
DragEnter Occurs when the input system reports an underlying drag event with this element as the target. (Ereditata da UIElement)
DragLeave Occurs when the input system reports an underlying drag event with this element as the origin. (Ereditata da UIElement)
DragOver Occurs when the input system reports an underlying drag event with this element as the potential drop target. (Ereditata da UIElement)
Drop Occurs when the input system reports an underlying drop event with this element as the drop target. (Ereditata da UIElement)
GotFocus Occurs when a UIElement receives focus. (Ereditata da UIElement)
Holding Occurs when an otherwise unhandled Hold interaction occurs over the hit test area of this element. (Ereditata da UIElement)
KeyDown Occurs when a keyboard key is pressed while the UIElement has focus. (Ereditata da UIElement)
KeyUp Occurs when a keyboard key is released while the UIElement has focus. (Ereditata da UIElement)
LayoutUpdated Occurs when the layout of the visual tree changes, due to layout-relevant properties changing value or some other action that refreshes the layout. (Ereditata da FrameworkElement)
Loaded Occurs when a FrameworkElement has been constructed and added to the object tree, and is ready for interaction. (Ereditata da FrameworkElement)
LostFocus Occurs when a UIElement loses focus. (Ereditata da UIElement)
ManipulationCompleted Occurs when a manipulation on the UIElement is complete. (Ereditata da UIElement)
ManipulationDelta Occurs when the input device changes position during a manipulation. (Ereditata da UIElement)
ManipulationInertiaStarting Occurs when the input device loses contact with the UIElement object during a manipulation and inertia begins. (Ereditata da UIElement)
ManipulationStarted Occurs when an input device begins a manipulation on the UIElement. (Ereditata da UIElement)
ManipulationStarting Occurs when the manipulation processor is first created. (Ereditata da UIElement)
Opened Fires when the IsOpen property is set to true.
PointerCanceled Occurs when a pointer that made contact abnormally loses contact. (Ereditata da UIElement)
PointerCaptureLost Occurs when pointer capture previously held by this element moves to another element or elsewhere. (Ereditata da UIElement)
PointerEntered Occurs when a pointer enters the hit test area of this element. (Ereditata da UIElement)
PointerExited Occurs when a pointer leaves the hit test area of this element. (Ereditata da UIElement)
PointerMoved Occurs when a pointer moves while the pointer remains within the hit test area of this element. (Ereditata da UIElement)
PointerPressed Occurs when the pointer device initiates a Press action within this element. (Ereditata da UIElement)
PointerReleased Occurs when the pointer device that previously initiated a Press action is released, while within this element. (Ereditata da UIElement)
PointerWheelChanged Occurs when the delta value of a pointer wheel changes. (Ereditata da UIElement)
RightTapped Occurs when a right-tap input stimulus happens while the pointer is over the element. (Ereditata da UIElement)
SizeChanged Occurs when either the ActualHeight or the ActualWidth property changes value on a FrameworkElement. (Ereditata da FrameworkElement)
Tapped Occurs when an otherwise unhandled Tap interaction occurs over the hit test area of this element. (Ereditata da UIElement)
Unloaded Occurs when this object is no longer connected to the main object tree. (Ereditata da FrameworkElement)

 

Metodi

The Popup Classe dispone di tali metodi. Eredita inoltre i metodi da Object Classe.

MetodoDescrizione
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. (Ereditata da UIElement)
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. (Ereditata da UIElement)
ArrangeOverride Provides the behavior for the Arrange pass of layout. Classes can override this method to define their own Arrange pass behavior. (Ereditata da FrameworkElement)
CancelDirectManipulations Cancels ongoing direct manipulation processing (system-defined panning/zooming) on any ScrollViewer parent that contains the current UIElement. (Ereditata da UIElement)
CapturePointer Sets pointer capture to a UIElement. Once captured, only the element that has capture will fire pointer-related events. (Ereditata da UIElement)
ClearValue Clears the local value of a dependency property. (Ereditata da DependencyObject)
FindName Retrieves an object that has the specified identifier name. (Ereditata da FrameworkElement)
FindSubElementsForTouchTargeting Enables a UIElement subclass to expose child elements that assist with resolving touch targeting. (Ereditata da UIElement)
GetAnimationBaseValue Returns any base value established for a dependency property, which would apply in cases where an animation is not active. (Ereditata da DependencyObject)
GetBindingExpression Returns the BindingExpression that represents the binding on the specified property. (Ereditata da FrameworkElement)
GetValue Returns the current effective value of a dependency property from a DependencyObject. (Ereditata da DependencyObject)
GoToElementStateCore When implemented in a derived class, enables per-state construction of a visual tree for a control template in code, rather than by loading XAML for all states at control startup. (Ereditata da FrameworkElement)
InvalidateArrange Invalidates the arrange state (layout) for a UIElement. After the invalidation, the UIElement will have its layout updated, which will occur asynchronously. (Ereditata da UIElement)
InvalidateMeasure Invalidates the measurement state (layout) for a UIElement. (Ereditata da 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. (Ereditata da 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. (Ereditata da FrameworkElement)
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. (Ereditata da FrameworkElement)
OnCreateAutomationPeer When implemented in a derived class, returns class-specific AutomationPeer implementations for the Microsoft UI Automation infrastructure. (Ereditata da 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. (Ereditata da UIElement)
ReadLocalValue Returns the local value of a dependency property, if a local value is set. (Ereditata da DependencyObject)
ReleasePointerCapture Releases pointer captures for capture of one specific pointer by this UIElement. (Ereditata da UIElement)
ReleasePointerCaptures Releases all pointer captures held by this element. (Ereditata da UIElement)
RemoveHandler Removes the specified routed event handler from this UIElement. Typically the handler in question was added by AddHandler. (Ereditata da UIElement)
SetBinding Attaches a binding to a FrameworkElement, using the provided binding object. (Ereditata da FrameworkElement)
SetValue Sets the local value of a dependency property on a DependencyObject. (Ereditata da DependencyObject)
TransformToVisual Returns a transform object that can be used to transform coordinates from the UIElement to the specified object. (Ereditata da UIElement)
UpdateLayout Ensures that all positions of child objects of a UIElement are properly updated for layout. (Ereditata da UIElement)

 

Proprietà

Classe dispone di tali proprietà. di Popup

ProprietàTipo di accessoDescrizione

ActualHeight

Sola letturaGets the rendered height of a FrameworkElement. (Ereditata da FrameworkElement)

ActualWidth

Sola letturaGets the rendered width of a FrameworkElement. (Ereditata da FrameworkElement)

AllowDrop

Lettura/scritturaGets or sets a value that determines whether this UIElement can be a drop target for purposes of drag-and-drop operations. (Ereditata da UIElement)

BaseUri

Sola letturaGets 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. (Ereditata da FrameworkElement)

CacheMode

Lettura/scritturaGets or sets a value that indicates that rendered content should be cached as a composited bitmap when possible. (Ereditata da UIElement)

Child

Lettura/scritturaGets or sets the content to be hosted in the popup.

ChildProperty

Sola letturaGets the identifier for the Child dependency property.

ChildTransitions

Lettura/scritturaGets or sets the collection of Transition style elements that apply to child content of a Popup.

ChildTransitionsProperty

Sola letturaIdentifies the ChildTransitions dependency property.

Clip

Lettura/scritturaGets or sets the RectangleGeometry used to define the outline of the contents of a UIElement. (Ereditata da UIElement)

CompositeMode

Lettura/scritturaGets or sets a property that declares alternate composition and blending modes for the element in its parent layout and window. This is relevant for elements that are involved in a mixed XAML / Microsoft DirectX UI. (Ereditata da UIElement)

DataContext

Lettura/scritturaGets or sets the data context for a FrameworkElement when it participates in data binding. (Ereditata da FrameworkElement)

DesiredSize

Sola letturaGets the size that this UIElement computed during the measure pass of the layout process. (Ereditata da UIElement)

Dispatcher

Sola letturaGets the CoreDispatcher that this object is associated with. (Ereditata da DependencyObject)

FlowDirection

Lettura/scritturaGets 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. (Ereditata da FrameworkElement)

Height

Lettura/scritturaGets or sets the suggested height of a FrameworkElement. (Ereditata da FrameworkElement)

HorizontalAlignment

Lettura/scritturaGets 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. (Ereditata da FrameworkElement)

HorizontalOffset

Lettura/scritturaGets or sets the distance between the left side of the application window and the left side of the popup.

HorizontalOffsetProperty

Sola letturaGets the identifier for the HorizontalOffset dependency property.

IsDoubleTapEnabled

Lettura/scritturaGets or sets a value that determines whether the DoubleTapped event can originate from that element. (Ereditata da UIElement)

IsHitTestVisible

Lettura/scritturaGets or sets whether the contained area of this UIElement can return true values for hit testing. (Ereditata da UIElement)

IsHoldingEnabled

Lettura/scritturaGets or sets a value that determines whether the Holding event can originate from that element. (Ereditata da UIElement)

IsLightDismissEnabled

Lettura/scritturaGets or sets a value that determines how the Popup can be dismissed.

IsLightDismissEnabledProperty

Sola letturaIdentifies the IsLightDismissEnabled dependency property.

IsOpen

Lettura/scritturaGets or sets whether the popup is currently displayed on the screen.

IsOpenProperty

Sola letturaGets the identifier for the IsOpen dependency property.

IsRightTapEnabled

Lettura/scritturaGets or sets a value that determines whether the RightTapped event can originate from that element. (Ereditata da UIElement)

IsTapEnabled

Lettura/scritturaGets or sets a value that determines whether the Tapped event can originate from that element. (Ereditata da UIElement)

Language

Lettura/scritturaGets 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. (Ereditata da FrameworkElement)

ManipulationMode

Lettura/scritturaGets or sets the ManipulationModes value used for UIElement behavior and interaction with gestures. Setting this value enables handling the manipulation events from this element in app code. (Ereditata da UIElement)

Margin

Lettura/scritturaGets or sets the outer margin of a FrameworkElement. (Ereditata da FrameworkElement)

MaxHeight

Lettura/scritturaGets or sets the maximum height constraint of a FrameworkElement. (Ereditata da FrameworkElement)

MaxWidth

Lettura/scritturaGets or sets the maximum width constraint of a FrameworkElement. (Ereditata da FrameworkElement)

MinHeight

Lettura/scritturaGets or sets the minimum height constraint of a FrameworkElement. (Ereditata da FrameworkElement)

MinWidth

Lettura/scritturaGets or sets the minimum width constraint of a FrameworkElement. (Ereditata da FrameworkElement)

Name

Lettura/scritturaGets 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. (Ereditata da FrameworkElement)

Opacity

Lettura/scritturaGets or sets the degree of the object's opacity. (Ereditata da UIElement)

Parent

Sola letturaGets the parent object of this FrameworkElement in the object tree. (Ereditata da FrameworkElement)

PointerCaptures

Sola letturaGets the set of all captured pointers, represented as Pointer values. (Ereditata da UIElement)

Projection

Lettura/scritturaGets or sets the perspective projection (3-D effect) to apply when rendering this element. (Ereditata da UIElement)

RenderSize

Sola letturaGets the final render size of a UIElement. (Ereditata da UIElement)

RenderTransform

Lettura/scritturaGets or sets transform information that affects the rendering position of a UIElement. (Ereditata da UIElement)

RenderTransformOrigin

Lettura/scritturaGets or sets the origin point of any possible render transform declared by RenderTransform, relative to the bounds of the UIElement. (Ereditata da UIElement)

RequestedTheme

Lettura/scritturaGets or sets the UI theme that is used by the UIElement (and its child elements) for resource determination. The UI theme you specify with RequestedTheme can override the app-level RequestedTheme. (Ereditata da FrameworkElement)

Resources

Lettura/scritturaGets 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. (Ereditata da FrameworkElement)

Style

Lettura/scritturaGets or sets an instance Style that is applied for this object during layout and rendering. (Ereditata da FrameworkElement)

Tag

Lettura/scritturaGets or sets an arbitrary object value that can be used to store custom information about this object. (Ereditata da FrameworkElement)

Transitions

Lettura/scritturaGets or sets the collection of Transition style elements that apply to a UIElement. (Ereditata da UIElement)

Triggers

Sola letturaGets the collection of triggers for animations that are defined for a FrameworkElement. Not commonly used. (Ereditata da FrameworkElement)

UseLayoutRounding

Lettura/scritturaGets 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. (Ereditata da UIElement)

VerticalAlignment

Lettura/scritturaGets 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. (Ereditata da FrameworkElement)

VerticalOffset

Lettura/scritturaGets or sets the distance between the top of the application window and the top of the popup.

VerticalOffsetProperty

Sola letturaGets the identifier for the VerticalOffset dependency property.

Visibility

Lettura/scritturaGets 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. (Ereditata da UIElement)

Width

Lettura/scritturaGets or sets the width of a FrameworkElement. (Ereditata da FrameworkElement)

 

Note

Non utilizzare un elemento Popup se è più appropriato utilizzare Flyout, MenuFlyout, ToolTip o MessageDialog.

Popup è un contenitore di utilizzo generale per l'hosting di elementi UIElement all'inizio del contenuto esistente. Si utilizza in genere un oggetto Popup per visualizzare temporaneamente il contenuto che esegue una determinata attività. L'oggetto Popup non dispone di un modello visivo predefinito. Al contrario, è necessario impostare il contenuto manualmente specificando un solo elemento Child come contenuto. È possibile definire il contenuto inline dell'elemento Popup, ma è pratica comune definire il contenuto come UserControl, quindi impostare UserControl come Child di Popup.

Per posizionare un oggetto Popup, impostare le proprietà HorizontalOffset e VerticalOffset. L'elemento Popup è spostato in relazione al relativo contenitore padre immediato. Popup non è modale, pertanto non viene bloccato l'input nella schermata sottostante.

Per visualizzare un elemento Popup, impostarne la proprietà IsOpen su true. Per nascondere l'oggetto Popup, impostare IsOpen su false. È possibile impostare IsLightDismissEnabled per nascondere automaticamente l'oggetto Popup quando un utente tocca un punto qualsiasi esterno a esso.

L'elemento Popup può ospitare controlli di input. Quando vengono ospitati controlli di input come TextBox, la tastiera touchscreen potrebbe venire visualizzata quando l'utente tocca il controllo di input. Se il contenitore padre di Popup è già nella struttura ad albero visuale, l'elemento Popup si riposiziona automaticamente quando viene visualizzata la tastiera touchscreen. In caso contrario l'elemento Popup non viene riposizionato e la tastiera touchscreen può coprirlo. Ciò può verificarsi se si crea l'elemento Popup nel codice e si imposta IsOpen su true senza aggiungere l'elemento Popup come figlio di un elemento nella struttura ad albero visuale.

Per altri esempi di codice che illustrano il controllo Popup, vedere l'esempio di popup XAML.

Esempi

Questo esempio mostra un semplice elemento Popup con contenuto definito inline.


<Grid x:Name="Output" HorizontalAlignment="Left" VerticalAlignment="Top" Grid.Row="1">
    <StackPanel>
        <Button Content="Show Popup (using Offset)" Click="ShowPopupOffsetClicked" />
    </StackPanel>
    <Popup VerticalOffset="10" HorizontalOffset="200" x:Name="StandardPopup">
        <Border BorderBrush="{StaticResource ApplicationForegroundThemeBrush}" 
                Background="{StaticResource ApplicationPageBackgroundThemeBrush}"
                BorderThickness="2" Width="200" Height="200">
            <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
                <TextBlock Text="Simple Popup" FontSize="24.667" HorizontalAlignment="Center" />
                <Button Content="Close" Click="ClosePopupClicked" HorizontalAlignment="Center" />
            </StackPanel>
        </Border>
    </Popup>
</Grid>


// Handles the Click event on the Button inside the Popup control and 
// closes the Popup. 
private void ClosePopupClicked(object sender, RoutedEventArgs e)
{
    // if the Popup is open, then close it 
    if (StandardPopup.IsOpen) { StandardPopup.IsOpen = false; }
}

// Handles the Click event on the Button on the page and opens the Popup. 
private void ShowPopupOffsetClicked(object sender, RoutedEventArgs e)
{
    // open the Popup if it isn't open already 
    if (!StandardPopup.IsOpen) { StandardPopup.IsOpen = true; }
} 

Questo esempio mostra un elemento Popup con UserControl impostato come elemento Child. L'elemento UserControl definisce il contenuto di Popup.


<Popup x:Name="ParentedPopup" HorizontalOffset="200" VerticalOffset="200">
    <local:PopupInputContent />
</Popup>


<UserControl
    x:Class="XAMLPopup.PopupInputContent"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:PopupExample"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:DesignHeight="300"
    d:DesignWidth="400">
    <Grid>
        <StackPanel>
            <TextBlock Text="Type some input" FontSize="24.667" />
            <TextBox Width="300" Height="55" />
            <Button Content="Save" Click="SimulateSaveClicked" />
        </StackPanel>
    </Grid>
</UserControl>


using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;

namespace XAMLPopup
{
    public sealed partial class PopupInputContent : UserControl
    {
        public PopupInputContent()
        {
            this.InitializeComponent();
        }

        // Handles the Click event of the 'Save' button simulating a save and close 
        private void SimulateSaveClicked(object sender, RoutedEventArgs e)
        {
            // in this example we assume the parent of the UserControl is a Popup 
            Popup p = this.Parent as Popup;

            // close the Popup
            if (p != null) { p.IsOpen = false; }  
        } 
    }
}

Requisiti

Client supportato minimo

Windows 8 [Solo applicazioni Windows Store]

Server supportato minimo

Windows Server 2012 [Solo applicazioni Windows Store]

Spazio dei nomi

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

Metadati

Windows.winmd

Vedere anche

FrameworkElement

 

 

Mostra:
© 2015 Microsoft