TabFormControlBase.AddPageButton Property
Provides access to the Add button, and allows you to bind a command executed with a button click.
Namespace: DevExpress.XtraBars
Assembly: DevExpress.XtraBars.v24.1.dll
NuGet Package: DevExpress.Win.Navigation
Declaration
Property Value
Type | Description |
---|---|
DevExpress.XtraBars.TabFormAddPageButton | A DevExpress.XtraBars.TabFormAddPageButton object that represents the Add button. |
Remarks
If the TabFormControlBase.ShowAddPageButton setting is enabled, the TabForm displays the built-in Add button.
By default, with a click on that button, an end-user creates a new tab page. This button supports the WinForms MVVM Framework, and it is possible to bind it with a DelegateCommand. The AddPageButton property provides access to the button, and allows you to bind a DelegateCommand using the BindCommand method. The code snippet below shows how to show a message box and create a new tab page with a click on the button, using the DelegateCommand object.
using DevExpress.Mvvm;
DelegateCommand command = new DelegateCommand(() => {
MessageBox.Show("Hello! I'm running!");
tabFormControl1.AddNewPage();
});
tabFormControl1.AddPageButton.BindCommand(command);
Note that if a custom command is bound to the Add button, the default action (creating a new page) is not performed. To create a new page in the bound command, use the TabFormControlBase.AddNewPage method.
If a command is bound to the button, the button visibility depends on whether the command can be executed. If the command cannot be executed, the button is automatically hidden. To specify whether the command can be executed, use the DelegateCommand constructor with the corresponding parameters. For more details, see the Commands topic in the WinForms MVVM documentation.