This project is read-only.

Content Disappears when Undocking/Floating

Aug 18, 2010 at 3:14 PM

Every time I've taken another look at AvalonDock, it has exhibited a behavior that makes no sense at all to me, and thwarted any chance of me integrating it into my application.

Consider this very simple use case:

    <ad:ResizingPanel Orientation="Horizontal">
            <ad:DockableContent x:Name="articles" Title="Articles" Content="{Binding ArticleList}"/>
            <ad:DocumentContent x:Name="articleDetails" Title="{Binding ArticleDetails.Title}" Content="{Binding ArticleDetails}"/>

The ArticleList and ArticleDetails properties yield view models that are mapped to views via DataTemplates like this:

<DataTemplate DataType="{x:Type viewModels:ArticleListViewModel}">

The ArticleListView is basically a big ListView of articles, whilst the ArticleDetailsView provides detailed information on a selected article.

When I first run the app, everything looks fine. I can select an article and it will appear in the document window. However, everything falls apart when I undock the article list. When I do that, the content disappears completely. If I dock the article list again, the content reappears. If I float the article list, the content disappears. If I dock it again, the content still doesn't appear until I resize the docking area.

The last time I ran into this issue, I believe I found that the DataContext was being pulled from underneath me, which made no sense at all then, and still doesn't now. Snoop doesn't appear to work with undocked/floated windows so I can't validate there easily.

Am I doing something fundamentally stupid here? What am I not understanding?


Aug 18, 2010 at 3:58 PM

I've found that doing this works around the issue:

<ad:DockableContent x:Name="articles" Title="Articles" DataContext="{Binding ArticleList}">
    <ContentControl Content="{Binding}"/>

I'm not sure why, but I suspect the docking manager is swapping out the content of the DockableContent instance. Thus, if the content simply binds to the DataContext then it doesn't matter if it gets swapped out.

I'm a little concerned that this issue will cause issue elsewhere, though.


Aug 18, 2010 at 4:08 PM
Edited Aug 18, 2010 at 4:09 PM

are you aware of the wiki page "Binding issues"?

I think your issue you encountered is mentioned / discussed there, too.

Aug 18, 2010 at 4:23 PM

Thanks - I just read that and came here to reply as such.

Yes, that does explain the issue. I think I'll stick with my approach for working around this for now.