Skip to content

Latest commit

 

History

History
55 lines (40 loc) · 1.79 KB

navigationview_expanding.md

File metadata and controls

55 lines (40 loc) · 1.79 KB
-api-id -api-type
E:Microsoft.UI.Xaml.Controls.NavigationView.Expanding
winrt event

Microsoft.UI.Xaml.Controls.NavigationView.Expanding

-description

Occurs when a node in the tree starts to expand.

-remarks

In order to fill in nodes as they're expanding, set the HasUnrealizedChildren property to true, and then add the children during this Expanding event. See the TreeView example fill a node when it's expanding.

Analogous to TreeView.Expanding event.

-see-also

-examples

The following example creates a hierarchical NavigationView and sets up an event handler for the Expanding event called OnItemExpanding. In this event handler, the expanded item's Content property is set to display in the 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;
}

-xaml-syntax

<NavigationView Expanding="eventhandler" />