Child view disappears after Parent view is changed

Topics: Bugs
Apr 18, 2012 at 12:47 AM

I've been having trouble with the following issue for a couple of weeks, and haven't yet found the problem:

I have a ShellViewModel and associated ShellView that contains this ContentControl:

            <ContentControl x:Name="ShellContentControl" cal:View.Model="{Binding DemoViewModel}" cal:View.Context="{Binding DemoViewContext}">
            </ContentControl>

The different views that bind to DemoViewModel contain another ContentControl:

        <ContentControl x:Name="DemoContentControl" cal:View.Model="{Binding Path=RegionViewModelConductor.ActiveItem}" Height="50" Width="500">
            <Border/>
        </ContentControl>

When the application is initially loaded and DemoViewModel and RegionViewModelConductor are instantiated, everything displays as it should.  When the DemoViewContext is changed for the first time in the ShellViewModel, everything continues to be displayed properly - I see the new view attached to the DemoViewModel, and I see the DemoContentControl showing the view attached to RegionViewModelConductor.ActiveItem. 

The problem happens when DemoViewContext is changed back to what it was originally - the original view shown for DemoViewModel shows an empty white area where DemoContentControl is supposed to be.  In other words, the Child view attached to RegionViewModelConductor.ActiveItem disappears when its Parent view is changed back to what it was originally.  It's almost like CM is permanently moving the Child view attached to RegionViewModelConductor.ActiveItem to the newly created Parent view (attached to DemoViewModel), and removing it from the original Parent view (attached to DemoViewModel).

I hope this is clear.  If it's not let me know and I can provide screen shots.