TabView.TabCloseRequested 事件

定义

当用户尝试通过单击 x-to-close 按钮、Ctrl+F4 或鼠标轮关闭 Tab 时引发。

// Register
event_token TabCloseRequested(TypedEventHandler<TabView, TabViewTabCloseRequestedEventArgs const&> const& handler) const;

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

// Revoke with event_revoker
TabView::TabCloseRequested_revoker TabCloseRequested(auto_revoke_t, TypedEventHandler<TabView, TabViewTabCloseRequestedEventArgs const&> const& handler) const;
public event TypedEventHandler<TabView,TabViewTabCloseRequestedEventArgs> TabCloseRequested;
function onTabCloseRequested(eventArgs) { /* Your code */ }
tabView.addEventListener("tabcloserequested", onTabCloseRequested);
tabView.removeEventListener("tabcloserequested", onTabCloseRequested);
- or -
tabView.ontabcloserequested = onTabCloseRequested;
Public Custom Event TabCloseRequested As TypedEventHandler(Of TabView, TabViewTabCloseRequestedEventArgs) 

事件类型

示例

<TabView TabCloseRequested="Tabs_TabCloseRequested" />
// Remove the requested tab from the TabView
private void Tabs_TabCloseRequested(TabView sender, TabViewTabCloseRequestedEventArgs args)
{
    sender.TabItems.Remove(args.Tab);
}

注解

使用此事件可以通过从 TabItems 集合或数据项集合中删除请求的选项卡来关闭该选项卡。

适用于