wpf-devexpress-dot-xpf-dot-docking-dot-baselayoutitem-ff89638d.md
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.v25.2.dll
NuGet Package : DevExpress.Wpf.Docking
public ICommand CloseCommand { get; set; }
Public Property CloseCommand As ICommand
| Type | Description |
|---|---|
| ICommand |
A ICommand object that is executed when the current item’s close button (‘x’) is clicked.
|
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.
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.
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);
}
}
Private command = New DelegateCommand(Of BaseLayoutItem)(AddressOf Close)
'...
Public Overridable Property CanClose As Boolean
Private Sub Close(ByVal panel As BaseLayoutItem)
If CanClose Then
Dim it = TryCast(panel.DataContext, Item)
Items.Remove(it)
End If
End Sub
See Also
DockLayoutManager.ClosingBehavior