c# - 在 Avalon Dock 中,如何以编程方式隐藏 LayoutDocumentPane 项目并恢复它们

标签 c# wpf mvvm devexpress avalondock

我正在使用 devexpress,在上下文菜单上试图隐藏 RootPanel 中存在的许多 LayoutDocument 之一。

下面是文档 Pane xml 文件。

  <LayoutDocumentPane>
        <LayoutDocument Title="  View  " IsSelected="True" ContentId="view" CanClose="False" LastActivationTimeStamp="10/15/2018 12:17:44" />
      </LayoutDocumentPane>

Xaml代码如下

  <xcad:LayoutDocument Title="  View  "  CanClose="False"  ContentId="View"  >
        <dxg:GridControl Name="dataTable" EnableSmartColumnsGeneration="True" 
                         ItemsSource="{Binding View_InfoTable,Mode=TwoWay,NotifyOnSourceUpdated=True,NotifyOnTargetUpdated=True}" SelectionMode="Row" 
                         AutoGenerateColumns="AddNew"  AllowColumnMRUFilterList="True"  ShowAllTableValuesInFilterPopup="False">
            <dxg:GridControl.View>
                <dxg:TableView ShowAutoFilterRow="True"  UseGroupShadowIndent="False" ShowGroupPanel="False" ShowCriteriaInAutoFilterRow="True" AllowSorting="False" BestFitMode="VisibleRows" 
                               ShowFixedTotalSummary="False" >
                </dxg:TableView>
            </dxg:GridControl.View>
        </dxg:GridControl>
 </xcad:LayoutDocument>

经过大量调试和搜索后,我还没有找到任何解决方案来隐藏停靠面板并在单击某个按钮时恢复它们。

最佳答案

我在尝试了很多天的错误之后找到了一个方法。

 private void BarButtonItem_ItemClick(object sender, DevExpress.Xpf.Bars.ItemClickEventArgs e)
     {
     string currentDockPane = e.Item.Content.ToString();       
      switch (currentDockPane)
          {
            case "view":
           var currentLayout= StandardDockManager.Layout.Descendents().OfType<LayoutAnchorable>().Where(x => x.ContentId == "view").FirstOrDefault();
     //Get all the descendents of current dock manger and check for the LayoutAnchorable if its visible .
                if (currentLayout.IsVisible)
               (((Xceed.Wpf.AvalonDock.Layout.LayoutAnchorable)(currentLayout))).IsVisible = false;
                             else
               (((Xceed.Wpf.AvalonDock.Layout.LayoutAnchorable)(currentLayout))).IsVisible = true;
            break;
              .......................
        }
    }

关于c# - 在 Avalon Dock 中,如何以编程方式隐藏 LayoutDocumentPane 项目并恢复它们,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52869506/

相关文章:

c# - POST 方法中来自 JsonSerializer 的 NullReferenceException

c# - 为什么 C# 在向上转换后将实例的先前非 null 成员视为 null?

c# - 按嵌入文档排序

c# - 使用自定义矩形裁剪图像

wpf - WPF中的位图类

c# - 如何使 Sprite 可点击?

c# - WPF 更新绑定(bind)到数组中的元素

mvvm - MVVM 中事件处理的最佳实践是什么

wpf - 如何更改 RadGridView 中特定单元格的格式

wpf - MVVM Light Toolkit - RelayCommands、DelegateCommands 和 ObservableObjects