Share via


NavigationView.Expanding Événement

Définition

Se produit lorsqu’un nœud de l’arborescence commence à se développer.

Cette documentation s’applique à WinUI 2 pour UWP (pour WinUI dans le SDK d'application Windows, consultez les espaces de noms SDK d'application Windows).

// Register
event_token Expanding(TypedEventHandler<NavigationView, NavigationViewItemExpandingEventArgs const&> const& handler) const;

// Revoke with event_token
void Expanding(event_token const* cookie) const;

// Revoke with event_revoker
NavigationView::Expanding_revoker Expanding(auto_revoke_t, TypedEventHandler<NavigationView, NavigationViewItemExpandingEventArgs const&> const& handler) const;
public event TypedEventHandler<NavigationView,NavigationViewItemExpandingEventArgs> Expanding;
Public Custom Event Expanding As TypedEventHandler(Of NavigationView, NavigationViewItemExpandingEventArgs) 
<NavigationView Expanding="eventhandler" />

Type d'événement

Exemples

L’exemple suivant crée un NavigationView hiérarchique et configure un gestionnaire d’événements pour l’événement d’expansion appelé OnItemExpanding. Dans ce gestionnaire d’événements, la propriété Content de l’élément développé est définie pour s’afficher dans l’objet ExpandingItemLabel TextBlock.

<muxc:NavigationView x:Name="navview"
    MenuItemsSource="{x:Bind categories, Mode=OneWay}"
    Expanding="OnItemExpanding"
    Collapsed="OnItemCollapsed"
    PaneDisplayMode="Left">

    <StackPanel Margin="10,10,0,0">
        <TextBlock Margin="0,10,0,0" x:Name="ExpandingItemLabel" Text="Last Expanding: N/A"/>
        <TextBlock x:Name="CollapsedItemLabel" Text="Last Collapsed: N/A"/>
    </StackPanel>
</muxc:NavigationView>
private void OnItemExpanding(object sender, NavigationViewItemExpandingEventArgs e)
{
    var nvib = e.ExpandingItemContainer;
    var name = "Last Expanding: " + nvib.Content.ToString();
    ExpandingItemLabel.Text = name;
}

Remarques

Pour remplir les nœuds au fur et à mesure qu’ils se développent, définissez la propriété HasUnrealizedChildren sur true, puis ajoutez les enfants pendant cet événement de développement. Consultez l’exemple TreeView pour remplir un nœud lorsqu’il se développe.

Analogue à l’événement TreeView.Expanding .

S’applique à