Hi all,
I'm using AvalonDock 2.0.1746 with PRISM and in my project I add LayoutAnchorable dynamically. This is my code:
```
public bool BeforeInsertAnchorable(LayoutRoot layout, LayoutAnchorable anchorableToShow,
ILayoutContainer destinationContainer)
{
//AD wants to add the anchorable into destinationContainer
//just for test provide a new anchorablepane
//if the pane is floating let the manager go ahead
var destPane = destinationContainer as LayoutAnchorablePane;
if (destinationContainer != null && destinationContainer.FindParent() != null) return false;
string destPaneName;
if (anchorableToShow.Content is ChartTabView)
destPaneName = "ChartToolsPane";
else if (anchorableToShow.Content is TreeNodesView)
destPaneName = "TreeToolsPane";
else
return false;
var toolsPane = layout.Descendents().OfType().FirstOrDefault(d => d.Name == destPaneName);
if (toolsPane == null) return false;
toolsPane.Children.Add(anchorableToShow);
return true;
}
```
In new version the layout.Descendents() always return null for "ChartToolsPane"(the "TreeToolsPane" I create when programm starts), but in older version it's working fine.
What can I resolve this problem?
Thanks,
Arthur
Comments: ** Comment from web user: ElByte **
Hi,
I know this is not my thread, but I have the same issue and would like to see it resolved, rather then using my work-around. Do you still need a project emartin? I can put one together for you.
In the meantime, you can re-produce this in the following way:
* add at least two panels of one type in xaml In my case I have one document, two docable
* the second docable gets a name, but is empty, as I don't need it at startup
<aDock:LayoutAnchorablePane Name="commonView" DockMinHeight="110" DockHeight="110" >
</aDock:LayoutAnchorablePane>
* Create a LayoutUpdateStrategy
public bool BeforeInsertAnchorable(LayoutRoot layout, LayoutAnchorable anchorableToShow, ILayoutContainer destinationContainer)
{
var destCommonPane = layout.Descendents().OfType<LayoutAnchorablePane>().FirstOrDefault(d => d.Name.Equals("commonView"));
}
* first time around, destCommonPane will be null ! but as far as I can tell, since it is definded in xaml, it should return the panel, like it does with the other
* If you add a dummy control in xaml, and hide it, the pane will be found
* I personally add it via code, in this method as a workaround.
Oh, and I use the MVVM approach, so it's bound to a List
Just let me know if you still need a demo and I put one together
regards