NavigationView.Collapsed イベント

定義

ツリー内のノードが折りたたまれているときに発生します。

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

// Register
event_token Collapsed(TypedEventHandler<NavigationView, NavigationViewItemCollapsedEventArgs const&> const& handler) const;

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

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

イベントの種類

次の例では、階層 NavigationView を作成し、OnItemCollapsed という名前の Collapsed イベントのイベント ハンドラーを設定します。 このイベント ハンドラーでは、最後に折りたたまれたアイテムの Content プロパティが CollapsedItemLabel 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 OnItemCollapsed(object sender, NavigationViewItemCollapsedEventArgs e)
{
    var nvib = e.CollapsedItemContainer;
    var name = "Last Collapsed: " + nvib.Content;
    CollapsedItemLabel.Text = name;
}

注釈

TreeView.Collapse に似ています

適用対象