Dela via


CommandBar.DynamicOverflowItemsChanging Event

Definition

Occurs when items move into or out of the overflow menu.

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

Event Type

Windows requirements

Device family
Windows 10 Anniversary Edition (introduced in 10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v3.0)

Remarks

For event data, see DynamicOverflowItemsChangingEventArgs.

Starting in Windows 10, version 1607, CommandBar introduces a dynamic overflow feature. By default, PrimaryCommands automatically move in or out of the overflow area as the command bar width changes, for example, when users resize their app window. You can set the IsDynamicOverflowEnabled property to false to disable this behavior.

Dynamic overflow affects only the UI presentation of the commands, it doesn’t move commands from the PrimaryCommands collection to SecondaryCommands.

Version compatibility

The IsDynamicOverflowEnabled event is not available prior to Windows 10, version 1607. If your app’s 'minimum platform version' setting in Microsoft Visual Studio is less than the 'introduced version' shown in the Requirements block later in this page, you must design and test your app to account for this. For more info, see Version adaptive code.

Note

Dynamic overflow is available when your app is compiled for Windows 10, version 1607 and running on version 1607 (or later). Dynamic overflow is not available when your app is compiled for a previous version or is running on a previous version.

To avoid exceptions when your app runs on previous versions of Windows 10, do not connect this event without first performing a runtime check. This example shows how to use the ApiInformation class to check for the presence of this event before you use it.

<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;
    }
}

Applies to

See also