CommandBar.DynamicOverflowItemsChanging 事件

定義

發生于專案移入或移出溢位功能表時。

// Register
event_token DynamicOverflowItemsChanging(TypedEventHandler<CommandBar, DynamicOverflowItemsChangingEventArgs const&> const& handler) const;

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

// Revoke with event_revoker
CommandBar::DynamicOverflowItemsChanging_revoker DynamicOverflowItemsChanging(auto_revoke_t, TypedEventHandler<CommandBar, DynamicOverflowItemsChangingEventArgs const&> const& handler) const;
public event TypedEventHandler<CommandBar,DynamicOverflowItemsChangingEventArgs> DynamicOverflowItemsChanging;
function onDynamicOverflowItemsChanging(eventArgs) { /* Your code */ }
commandBar.addEventListener("dynamicoverflowitemschanging", onDynamicOverflowItemsChanging);
commandBar.removeEventListener("dynamicoverflowitemschanging", onDynamicOverflowItemsChanging);
- or -
commandBar.ondynamicoverflowitemschanging = onDynamicOverflowItemsChanging;
Public Custom Event DynamicOverflowItemsChanging As TypedEventHandler(Of CommandBar, DynamicOverflowItemsChangingEventArgs) 
<CommandBar DynamicOverflowItemsChanging="eventhandler"/>

事件類型

Windows 需求

裝置系列
Windows 10 Anniversary Edition (已於 10.0.14393.0 引進)
API contract
Windows.Foundation.UniversalApiContract (已於 v3.0 引進)

備註

如需事件資料,請參閱 DynamicOverflowItemsChangingEventArgs

從 Windows 10 1607 版開始,CommandBar引進了動態溢位功能。 根據預設, PrimaryCommands 會在命令列寬度變更時自動移入或移出溢位區域,例如,當使用者調整其應用程式視窗的大小時。 您可以將 IsDynamicOverflowEnabled 屬性設定為 false ,以停用此行為。

動態溢位只會影響命令的 UI 呈現,它不會將命令從PrimaryCommands 集合移至 SecondaryCommands

版本相容性

IsDynamicOverflowEnabled事件在 Windows 10 1607 版之前無法使用。 如果您的應用程式在 Microsoft Visual Studio 中的「最低平臺版本」設定小於此頁面稍後需求區塊中顯示的「引進版本」,您必須設計和測試您的應用程式以考慮此專案。 如需詳細資訊,請參閱 版本調適型程式碼

注意

當您的應用程式編譯Windows 10版本 1607 並在 1607 版 (或更新版本) 上執行時,可以使用動態溢位。 當您的應用程式針對舊版編譯或在舊版上執行時,無法使用動態溢位。

若要避免在舊版Windows 10上執行應用程式時發生例外狀況,請勿在沒有先執行執行時間檢查的情況下連線此事件。 此範例示範如何使用 ApiInformation 類別來檢查此事件是否存在,再使用它。

<CommandBar x:Name="commandBar1" Loaded="CommandBar_Loaded">
    ...
</CommandBar>
private void CommandBar_Loaded(object sender, RoutedEventArgs e)
{
    if (ApiInformation.IsEventPresent("Windows.UI.Xaml.Controls.CommandBar", "DynamicOverflowItemsChanging"))
    {
        commandBar1.DynamicOverflowItemsChanging += CommandBar1_DynamicOverflowItemsChanging;
    }
}

適用於

另請參閱