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와 유사

적용 대상