AvalonDock: Multiple tool windows layout
I'm using well-known docking library AvalonDock 2.0 in my WPF project. The library supports MVVM and that's what I'm trying to do. A sample MVVM test application is available on GitHub. I downloaded the sample and extended it to display the layout that I need, which roughly looks like this:
---------------------------
| | |
| | T1 |
| |----|
| Docs | |
| | T2 |
| |----|
| | |
| | T3 |
---------------------------
As you can see, I have a main documents area and a tools area that has 3 LayoutAnchorable
s that are docked to the right side and stacked vertically. Using MVVM, my window's ViewModel exposes a property named Tools
that returns an array containing ViewModels of all my tool windows. I then bind this property to AnchorablesSource
property of my docking control in XAML.
The problem however is that AvalonDock shows the 3 tool panes as 3 tabs instead of vertically stacking them.
Has anyone here used AvalonDock with MVVM? What is my way forward here? Does LayoutInitializer
class have any role in solving this issue?
Later research revealed that it is actually the job of LayoutInitializer
class to assign ViewModel objects to my LayoutAnchorablePane
s. The layout itself should still be defined within XAML (or through code-behind if u wish). This is correct from theoretical point of view too; the ViewModel shouldn't be responsible for managing the layout (View).
上一篇: 如何修改或禁用标题栏中的上下文菜单?
下一篇: AvalonDock:多个工具窗口布局