Back to Devexpress

BaseLayoutItem.CloseCommand Property

wpf-devexpress-dot-xpf-dot-docking-dot-baselayoutitem-ff89638d.md

latest4.0 KB
Original Source

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.v25.2.dll

NuGet Package : DevExpress.Wpf.Docking

Declaration

csharp
public ICommand CloseCommand { get; set; }
vb
Public Property CloseCommand As ICommand

Property Value

TypeDescription
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:

csharp
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);  
      }
  }
vb
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

Closed

Close(BaseLayoutItem)

RemovePanel(LayoutPanel)

DockLayoutManager.ClosingBehavior

BaseLayoutItem.ClosingBehavior

BaseLayoutItem Class

BaseLayoutItem Members

DevExpress.Xpf.Docking Namespace