views:

103

answers:

1

I can get the master-detail scenario to work just fine if I keep the master and details together in the same view. However I want to be able to tailor the details presentation based on user security. Therefore I moved the detail section to a separate view using the same viewmodel as a backend. Now the details dont update properly when a new master record is selected. If the two view are using the same viewmodel, shouldnt this work just fine? Like I said when the code is together in the same view it works ok.

detail XAML:

<ListView x:Name="DoctorOfficesList"
              Grid.Column="1"
              Background="black"
              HorizontalContentAlignment="Stretch"
              IsSynchronizedWithCurrentItem="True"
              ItemsSource="{Binding Path=SelectedDoctor.DoctorOfficesCollection}"
              ItemTemplate="{StaticResource DoctorOfficesListTemplate}">
    </ListView>

Master XAML:

<ListBox x:Name="DoctorHeaderList"
             Grid.Column="0"
             MinWidth="200"
             MaxWidth="300"
             Margin="0,0,2,0"
             Background="black"
             ItemsSource="{Binding Path=DoctorsList}"
             SelectedItem="{Binding Path=SelectedDoctor}"
             IsSynchronizedWithCurrentItem="True"
             ItemTemplate="{StaticResource DoctorsListTemplate}"
             ScrollViewer.HorizontalScrollBarVisibility="Hidden">
    </ListBox>

I have tried several ways to get this to work. All scenarios work when the listboxes are in the same view. When moved separately they stop. If it matters I am using PRISMv2 as well.

I guess my specific question is how do I get this to work? Do i really need an event? I would think since they are tied to the same VM this would be a snap.

+1  A: 

Are you sure both views are using the same instance of the view model? I occasionally implement a property in my view model that exposes the result of GetHashCode() and bind a TextBlock to it in the view just to double-check that two things that are supposed to be bound to the same instance actually are.

Robert Rossney
ill try that, the viewmodel is being injected by unity, and I think i have it as a conatinercontrolledlifetime, but i will definately check that now...thanks.
ecathell
I had not registered a default viewmodel with the ioc container...I have now done that and it works correctly...Thanks for your help!
ecathell