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"/>

事件類型

備註

如需事件數據,請參閱 DynamicOverflowItemsChangingEventArgs

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

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

版本相容性

IsDynamicOverflowEnabled 事件在 Windows 10 1607 版之前無法使用。 如果您的 App 在 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;
    }
}

適用於

另請參閱