TabView.TabDroppedOutside 事件

定義

發生於使用者卸除 TabStrip 區域外的索引標籤來完成拖放作業時。

// Register
event_token TabDroppedOutside(TypedEventHandler<TabView, TabViewTabDroppedOutsideEventArgs const&> const& handler) const;

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

// Revoke with event_revoker
TabView::TabDroppedOutside_revoker TabDroppedOutside(auto_revoke_t, TypedEventHandler<TabView, TabViewTabDroppedOutsideEventArgs const&> const& handler) const;
public event TypedEventHandler<TabView,TabViewTabDroppedOutsideEventArgs> TabDroppedOutside;
function onTabDroppedOutside(eventArgs) { /* Your code */ }
tabView.addEventListener("tabdroppedoutside", onTabDroppedOutside);
tabView.removeEventListener("tabdroppedoutside", onTabDroppedOutside);
- or -
tabView.ontabdroppedoutside = onTabDroppedOutside;
Public Custom Event TabDroppedOutside As TypedEventHandler(Of TabView, TabViewTabDroppedOutsideEventArgs) 

事件類型

範例

提示

如需詳細資訊、設計指引和程式代碼範例,請參閱 TabView

WinUI 3 資源庫應用程式包含大部分 WinUI 3 控制件、特性和功能的互動式範例。 從 Microsoft Store 取得應用程式,或在 GitHub 上取得原始程式碼。

<TabView TabDroppedOutside="TabView_TabDroppedOutside">
// NOTE: The app is responsible for writing this code. A full sample can be found in the Xaml Controls Gallery.
private async void TabView_TabDroppedOutside(TabView sender, TabDroppedOutsideEventArgs e)
{
    // Create a new AppWindow
    AppWindow newWindow = await AppWindow.TryCreateAsync();

    // Create the content for the new window
    var newPage = new MainPage();

    // Remove tab from existing list
    Tabs.TabItems.Remove(e.Tab);

    // Add tab to list of Tabs on new page
    newPage.AddItemToTabs(e.Tab);

    // Set the Window's content to the new page
    ElementCompositionPreview.SetAppWindowContent(newWindow, newPage);

    // Show the window
    await newWindow.TryShowAsync();
}

備註

您可以使用此事件來建立新的視窗。

內容可以裝載在應用程式內的方式不同。 應用程式檔的 [顯示多個檢視 ] 概述顯示多個檢視或視窗的各種技術。

下列範例使用AppWindow,從Windows 10 1903版 (SDK 18362) 開始提供。 AppWindow 可簡化多視窗 UWP 應用程式的建立,因為它會在建立來源的相同 UI 線程上運作。

如果您的應用程式以小於 1903 Windows 10 版本為目標,您必須使用 CoreWindow/ApplicationView。 Windows 社群工具組 TabView 卸除範例 示範如何使用 CoreWindow/ApplicationView 建立多視窗應用程式。

適用於