如何拉伸/最大化 AvalonDock 文档窗格
我在 .NET 3.5 上使用 AvalonDock v 1.3。
我在设计时向 DockingManager 添加了两个文档窗格。第一个设置为可见,第二个设置为隐藏/折叠(请参阅下面的 Visibility="Collapsed")。
当我启动应用程序时,第二个文档窗格不可见,这是预期的行为,但不幸的是,可见文档面板不会显示拉伸到主窗口的边缘,尽管 HorizontalAlignment 是设置为“拉伸”。我将如何使这个剪辑(或最大化)到允许区域的边缘?
这是我正在使用的 xaml:
<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>
谢谢, 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>
I am using AvalonDock v 1.3 on .NET 3.5.
I have added two Document Panes at design time to a DockingManager. The first one is set to be visible and the second is hidden/collapsed (see Visibility="Collapsed" below).
When I launch the application, the second Document Pane is not visible, which is the intended behaviour but unfortunately, the visible document panel does not display stretched to the edges of the main window despite the fact that HorizontalAlignment is set to "Stretched". How would I go about making this clip(or maximise) to the edges of the allowed area?
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
As per request, here is the full 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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你是对的,在 XAML 中定义
collapsedDocumentPane
似乎有问题,因为AvalonDoc
将为它保留空间(它是选项卡标题或其他内容),完全忽略Visibility= “崩溃”
,所以我最终在代码中添加/删除了我的。所以:首先,从 XAML 中删除您的
"collapsedDocumentPane"
(我将其注释掉,以便稍后可以将其用作后面代码的引用):并在后面的代码中重新创建该 xaml(在您中
xaml.cs
文件):然后是添加或删除它的方法:
注意,该属性是延迟加载的 - 仅在需要时构造。
所以现在你要做的就是在需要添加或删除时调用上面的方法。
这只是一个示例,您可以向方法添加一个参数来告诉它要做什么,或者其他什么,希望这可以帮助/让您继续前进。
You are right, it seems problematic to define your
collapsedDocumentPane
in XAML, asAvalonDoc
will reserve the space for it (it's tab header or whatever) completely disregardingVisibility="Collapsed"
, so I ended up adding/removinhg mine in code. So:First, remove your
"collapsedDocumentPane"
from XAML (I am commenting it out, so that it can be used as a reference from code behind later):And recreated that xaml in code behind (in you
xaml.cs
file):Then a method that adds or removes it:
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.