NavigationView.Expanding Event
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Occurs when a node in the tree starts to expand.
// 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;
function onExpanding(eventArgs) { /* Your code */ }
navigationView.addEventListener("expanding", onExpanding);
navigationView.removeEventListener("expanding", onExpanding);
- or -
navigationView.onexpanding = onExpanding;
Public Custom Event Expanding As TypedEventHandler(Of NavigationView, NavigationViewItemExpandingEventArgs)
<NavigationView Expanding="eventhandler" />
Event Type
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.
<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>
</NavigationView>
private void OnItemExpanding(object sender, NavigationViewItemExpandingEventArgs e)
{
var nvib = e.ExpandingItemContainer;
var name = "Last Expanding: " + nvib.Content.ToString();
ExpandingItemLabel.Text = name;
}
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.