Skip to main content

BaseLayoutItem.CloseCommand Property

Gets or sets a command that is executed when the current item’s close button (‘x’) is clicked. This is a dependency property.

Namespace: DevExpress.Xpf.Docking

Assembly: DevExpress.Xpf.Docking.v24.2.dll

NuGet Package: DevExpress.Wpf.Docking

Declaration

public ICommand CloseCommand { get; set; }

Property Value

Type Description
ICommand

A ICommand object that is executed when the current item’s close button (‘x’) is clicked.

Remarks

A Command is not Assigned to the CloseCommand Property

If no command is assigned to the CloseCommand property, the current item is removed from the view when the item is closed.

After the item is closed, it is removed or stored in the DockLayoutManager.ClosedPanels collection. The DockLayoutManager.ClosingBehavior and BaseLayoutItem.ClosingBehavior properties specify whether the item is closed or removed.

A Command is Assigned to the CloseCommand Property

If a command is assigned to the CloseCommand property and can be executed, the current item is not removed from the view and is not closed.

In this case, you can use the DockControllerBase.Close method to close the item, or use the DockControllerBase.RemovePanel method to remove the item from the DockLayoutManager.

The CloseCommand is not executed when the item is closed with the BaseLayoutItem.Closed property or the DockControllerBase.Close method.

Remove the Item in MVVM Applications

The following code sample removes the panel when a user clicks the panel’s (x) button:

var command = new DelegateCommand<BaseLayoutItem>(Close);  
// ...
public virtual bool CanClose { get; set; }  
  void Close(BaseLayoutItem panel) {  
      if (CanClose) {  
          var it = panel.DataContext as Item;  
          Items.Remove(it);  
      }
  }  
See Also