Back to Devexpress

BaseLayoutItem.AllowHide Property

wpf-devexpress-dot-xpf-dot-docking-dot-baselayoutitem-210a92b6.md

latest7.2 KB
Original Source

BaseLayoutItem.AllowHide Property

Gets or sets whether the item can be hidden (auto-hidden, for dock items). This is a dependency property.

Namespace : DevExpress.Xpf.Docking

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

NuGet Package : DevExpress.Wpf.Docking

Declaration

csharp
public bool AllowHide { get; set; }
vb
Public Property AllowHide As Boolean

Property Value

TypeDescription
Boolean

true, if the item can be hidden (auto-hidden, for dock items); otherwise, false.

|

Remarks

Hide Dock Items

In Xaml

Create an AutoHideGroup, add a panel to the group, and then add the group to the DockLayoutManager.AutoHideGroups collection.

xaml
<Window ...
  xmlns:dxdo="http://schemas.devexpress.com/winfx/2008/xaml/docking">
  <dxdo:DockLayoutManager>
    <dxdo:DockLayoutManager.AutoHideGroups>
      <dxdo:AutoHideGroup DockType="Right" AllowHide="True">
        <dxdo:LayoutPanel Caption="Panel1"/>
      </dxdo:AutoHideGroup>
    </dxdo:DockLayoutManager.AutoHideGroups>
  </dxdo:DockLayoutManager>
</Window>

In Code Behind

Use the DockController‘s IDockController.Hide methods to auto-hide a specific dock item.

csharp
DockLayoutManager1.DockController.Hide(Panel1, Dock.Right);
vb
DockLayoutManager1.DockController.Hide(Panel1, Dock.Right)

Hide Layout Items

Use the DockLayoutManager.LayoutController object’s LayoutController.Hide method to hide Layout items.

Panel’s Data Context

When you set the LayoutPanel‘s AutoHide property to true, the LayoutPanel DataContext can be changed, because the panel is placed inside a new AutoHideGroup.

Subscribe to the LayoutPanel’s DataContextChanging event to catch the moment when the panel’s DataContext is changed.

When this occurs, you can specify your own DataContext for the panel. Subscribe to the DockManager.DockOperationCompleted event to catch the moment when your panel is hidden, and specify your own DataContext.

The following code sample changes ContentPanel LayoutPanel ‘s DataContext when the panel is hidden:

csharp
private void dockManager_DockOperationCompleted(object sender, DevExpress.Xpf.Docking.Base.DockOperationCompletedEventArgs e) {
    if(e.Item.Name == "ContentPanel" && e.DockOperation == DockOperation.Hide ) {
        e.Item.DataContext = YourDataContext;
    }
}
vb
Private Sub dockManager_DockOperationCompleted(ByVal sender As Object, ByVal e As DevExpress.Xpf.Docking.Base.DockOperationCompletedEventArgs)
    If e.Item.Name = "ContentPanel" AndAlso e.DockOperation = DockOperation.Hide Then
        e.Item.DataContext = YourDataContext
    End If
End Sub

The following code snippets (auto-collected from DevExpress Examples) contain references to the AllowHide property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

wpf-diagram-mdi/CS/MainWindow.xaml#L158

xml
AllowDock="False"
AllowHide="False"
AllowMaximize="False"

wpf-dock-layout-manager-limit-layout-group-customization-at-runtime/CS/DXDockingForLayoutPurposes/DockLayoutManagerExt.cs#L75

csharp
var target = dockLayoutElementDragInfo.Target;
if ((dockLayoutElementDragInfo.DropTarget is HiddenItemElement || dockLayoutElementDragInfo.DropTarget is HiddenItemsListElement) && dockLayoutElementDragInfo.Item.AllowHide) {
    LayoutItemType itemType = dockLayoutElementDragInfo.Item.ItemType;

wpf-dock-layout-manager-limit-layout-group-customization-at-runtime/VB/DXDockingForLayoutPurposes/DockLayoutManagerExt.vb#L83

vb
Dim target = dockLayoutElementDragInfo.Target
If(TypeOf dockLayoutElementDragInfo.DropTarget Is HiddenItemElement OrElse TypeOf dockLayoutElementDragInfo.DropTarget Is HiddenItemsListElement) AndAlso dockLayoutElementDragInfo.Item.AllowHide Then
    Dim itemType As LayoutItemType = dockLayoutElementDragInfo.Item.ItemType

See Also

AutoHideGroups

DockItemHiding

DockItemHidden

LayoutItemHidden

ShowPinButton

BaseLayoutItem Class

BaseLayoutItem Members

DevExpress.Xpf.Docking Namespace