问题
I am creating panels in code in this way:
DockableContent dockableContent = CreateDockableContent<TView>(model);
dockableContent.Show(_dockingManager, AnchorStyle.Bottom);
How can I specify the initial height for that panel? The following doesn't work:
dockableContent.Height = 400;
or
ResizingPanel.SetResizeHeight(dockableContent, new GridLength(400));
回答1:
Nagg,
Setting the height of the panel only affects its appearance when floating. When it is docked, it is bound by the limits of Resizing panel (looks like you figured that out yourself).
Resizing panels are created with a default size in the AvalonDock library.
You might want to look into version 2.0 of AvalonDock - it offers way more flexibility in customizing Panels - especially because they can be bound to a ViewModel where you can change their appearance.
If you still want to use 1.3 then you'd have to modify the AvalonDock source code to get it to do what you want (add in a default panel height for example).
Steve
回答2:
For the panel with fixed height set DockMinHeight="120" and DockHeight="1*". For other panel set DockHeight="90*".
In this case, panel with fixed height will become so short, that DockMinHeight will be used.
回答3:
For Avalon Dock 2.0 there is some internal code that will automatically resize the DockWidth / DockHeight to star-size. Which stops you from having a fixed/initial height/width panel in a vertical / horizontal group pane.
The only fix at the moment I can see is to comment out this behavour from the AvalonDock Source code. Namely; in OnFixChildrenDockLengths
of class LayoutAnchorablePaneGroupControl
Hope this helps.
来源:https://stackoverflow.com/questions/9739876/setting-the-initial-height-for-panel-in-avalon-dock