English 中文(简体)
• 如何扩大AvalonDock文件Pane
原标题:How to stretch/maximise an AvalonDock DocumentPane

我正在使用AvalonDock诉1.3, NET 3.5。

我在设计时增加了两份文件Pans,以备震.Manager。 第一个目标被确定为可见,第二个是隐蔽的(见Visibility=“Collapsed”)。

当我提出申请时,第二份文件Pane被看见not<>em>,这是打算的行为,但不幸的是,尽管横向关系被定在“重新安排”上,但可见的文件小组却并未延伸到主要窗口的边缘。 我将如何把这个奇迹(或最大)放在允许区域的边缘?

This is the xaml that I am using:

   <ad:DockingManager x:Name="dockManager" Grid.Row="1">
        <ad:ResizingPanel Name="resizePanel" Orientation="Horizontal">
            <ad:DocumentPane Name="visibleDocumentPane" HorizontalAlignment="Stretch" >
                <ad:DocumentContent Title="A"/>
                <ad:DocumentContent Title="B"/>                    
            </ad:DocumentPane>
            <ad:DocumentPane Name="collapsedDocumentPane" Visibility="Collapsed">
                <ad:DocumentContent Title="A"/>
                <ad:DocumentContent Title="B"/>
            </ad:DocumentPane>
        </ad:ResizingPanel>
    </ad:DockingManager>

Thanks, Dave

根据要求,这是指全部XAML:

    <Window x:Class="AvalonDockSampleProject.MainWindow"
       xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
       xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
       xmlns:ad="clr-namespace:AvalonDock;assembly=AvalonDock"
      Title="MainWindow" Height="421" Width="948">
    <Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="24"/>
        <RowDefinition Height="*"/>
        <RowDefinition Height="24"/>
    </Grid.RowDefinitions>
    <Menu>
        <MenuItem Header="File">
            <MenuItem Header="Create DockableContent" Click="CreateDockableContent"/>
             <MenuItem Header="Layout">
                <MenuItem Header="Save" Click="SaveLayout"/>
                <MenuItem Header="Restore" Click="RestoreLayout"/>                    
            </MenuItem>
            <MenuItem Header="Exit"/>
        </MenuItem>
    </Menu>
    <ad:DockingManager x:Name="dockManager" Grid.Row="1">
        <ad:ResizingPanel Name="resizePanel" Orientation="Horizontal">
            <ad:DocumentPane Name="visibleDocumentPane" HorizontalAlignment="Stretch" >
                <ad:DocumentContent Title="A!"/>
                <ad:DocumentContent Title="B!"/>                    
            </ad:DocumentPane>
            <ad:DocumentPane Name="collapsedDocumentPane" Visibility="Collapsed">
                <ad:DocumentContent Title="A"/>
                <ad:DocumentContent Title="B"/>
            </ad:DocumentPane>
           </ad:ResizingPanel>
        </ad:DockingManager>                  
        <StatusBar Grid.Row="2">
            <StatusBarItem Content="AvalonDock 1.3 Sample Project"/>
        </StatusBar>
    </Grid>
</Window>
问题回答

您是正确的,在XAML中,似乎难以界定你的<代码>collapsedDocumentPane,作为AvalonDoc将空间保留给它(其制片头或任何东西)完全无视Visibility=“Collapsed”,因此,我最后在代码中添加/移除inhg 地雷。 因此:

首先,从XAML中删除“>“collapsedDocumentPane”

<ad:DockingManager x:Name="dockManager" Grid.Row="1">
    <ad:ResizingPanel Name="resizePanel" Orientation="Horizontal">
        <ad:DocumentPane Name="visibleDocumentPane" HorizontalAlignment="Stretch" >
            <ad:DocumentContent Title="A"/>
            <ad:DocumentContent Title="B"/>                    
        </ad:DocumentPane>
        <!--<ad:DocumentPane Name="collapsedDocumentPane" Visibility="Collapsed">
            <ad:DocumentContent Title="A"/>
            <ad:DocumentContent Title="B"/>
        </ad:DocumentPane>-->
    </ad:ResizingPanel>
</ad:DockingManager>

并重新计算背后编码中的xaml(见xaml.cs文档):

private DockablePane _collapsedDocumentPane;

private DockablePane CollapsedDocumentPane
{
  get
  {
    if (_collapsedDocumentPane== null)
    {
        _collapsedDocumentPane= new DockablePane();
        var a = new DockableContent
        {
           Title = "A",
           DataContext = _youViewModel, //if you pass data context
           DockableStyle = DockableStyle.AutoHide,
           Content = new RadGridView(), //just a sample control
         };
         var b = new DockableContent { Title = "B"};

        _collapsedDocumentPane.Items.Add(a);
        _collapsedDocumentPane.Items.Add(b);
     }
     return _errorsDockablePane;
   }
 }

之后,又采用一种方法补充或删除:

private void EvaluateCollapsedDocPaneVisibility()
{
   //don t know your scenario
   if (NeedToDisplay_CollapsedDocPane)
   {
       if (!resizePanel.Children.Contains(CollapsedDocumentPane))
         resizePanel.Children.Add(CollapsedDocumentPane);
   }
   else
   {
       if (resizePanel.Children.Contains(CollapsedDocumentPane))
         resizePanel.Children.Remove(CollapsedDocumentPane);
   }
 }

Note, the property is lazy loaded - constructed only when needed. So now all you gotta do is call the method above whenever you need to add or remove. This is just a sample, you can add an arg to the method to tell it what to do, or whatever, hope this helps/gets you going.





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...