NavigationView.Expanding イベント

定義

ツリー内のノードの展開が開始されたときに発生します。

このドキュメントは、UWP 用の WinUI 2 に適用されます (Windows アプリ SDKWinUI の場合は、Windows アプリ SDK名前空間を参照してください)。

// 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" />

イベントの種類

次の例では、階層 NavigationView を作成し、OnItemExpanding という名前の Expanding イベントのイベント ハンドラーを設定します。 このイベント ハンドラーでは、展開されたアイテムの Content プロパティが 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;
}

注釈

展開中にノードを入力するには、HasUnrealizedChildren プロパティを true に設定し、この Expanding イベント中に子を追加します。 展開 時にノードを塗りつぶす TreeView の例を参照してください。

TreeView.Expanding イベントに似ています。

適用対象