方式:使用AvalonDock.dll控制項。
AvalonDock有如下主要元素:
1.DockingManager: DockingManager是AvalonDock中最核心的控制項標籤,容納所有AvalonDock標籤。
2.ResizingPanel: 用於整體介面布局,方向有橫向和縱向。
3.DocumentPane:通常用於包含文字編輯的標籤,也可以包含DockableContents標籤,DocumentPane不能被拖動
4.DocumentContent:包含在DocumentPane裡面,一般用於文本編輯的功能,類似vs2010的代碼編輯框部分。
4.DockablePane:能夠類似vs2010的工具箱面板,能夠吸附在邊框上的效果。
5.DockableContent:包含在DockablePane裡面,下方顯示DockableContent的Title
下面來實現一個類似vs2010的介面,先貼上效果圖:
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="24"/>
<RowDefinition Height="*"/>
<RowDefinition Height="24"/>
</Grid.RowDefinitions>
<Menu>
<MenuItem Header="File">
<MenuItem Header="New Document" Click="NewDocument_Click" Name="NewDocument"/>
<MenuItem Header="Exit"/>
</MenuItem>
</Menu>
<my:DockingManager x:Name="dockManager" Grid.Row="1">
<my:ResizingPanel Orientation="Vertical">
<my:ResizingPanel Orientation="Horizontal">
<my:DocumentPane Name="DocumentPane1">
<my:DocumentContent Title="MyDocument1" Name="MyDoc1">
<TextBox Name="tbContents" VerticalScrollBarVisibility="Auto" AcceptsReturn="True" TextWrapping="Wrap"></TextBox>
</my:DocumentContent>
</my:DocumentPane>
<my:DockablePane my:ResizingPanel.ResizeWidth="150">
<my:DockableContent x:Name="classesContent" Title="Classes">
<TreeView>
<TreeViewItem Header="Class1"/>
<TreeViewItem Header="Class2"/>
</TreeView>
</my:DockableContent>
<my:DockableContent x:Name="toolsContent" Title="Tools">
<ListBox>
<ListBoxItem Content="Tool1"></ListBoxItem>
<ListBoxItem Content="Tool2"></ListBoxItem>
<ListBoxItem Content="Tool3"></ListBoxItem>
</ListBox>
</my:DockableContent>
</my:DockablePane>
</my:ResizingPanel>
<my:DockablePane my:ResizingPanel.ResizeHeight="100">
<my:DockableContent Title="Errors" x:Name="errorsContent">
<ListView>
<ListView.View>
<GridView>
<GridView.Columns>
<GridViewColumn Header="Error"/>
<GridViewColumn Header="Page"/>
<GridViewColumn Header="File"/>
<GridViewColumn Header="Row"/>
</GridView.Columns>
</GridView>
</ListView.View>
</ListView>
</my:DockableContent>
<my:DockableContent Title="Output" x:Name="output">
<TextBox IsReadOnly="True" AcceptsReturn="True"/>
</my:DockableContent>
</my:DockablePane>
</my:ResizingPanel>
</my:DockingManager>
<StatusBar Grid.Row="2">
<StatusBarItem Content="AvalonDock 1.3 Sample Project"/>
</StatusBar>
</Grid>