MVVM Light - master / child views and dependency properties

Posted by Carl Dickinson on Stack Overflow See other posts from Stack Overflow or by Carl Dickinson
Published on 2010-04-19T11:10:33Z Indexed on 2010/04/19 11:13 UTC
Read the original article Hit count: 358

Filed under:
|
|

I'm getting an odd problem when implementing a master / child view and custom dependency properties.

Within my master view I'm binding the view model declaratively in the XAML as follows:

DataContext="{Binding MainViewModelProperty, Source={StaticResource Locator}}"

and my MainViewModel is exposing an observable collection which I'm binding to an ItemsControl as follows:

        <ItemsControl ItemsSource="{Binding Lists}" Height="490" Canvas.Top="10" Width="70">
            <ItemsControl.ItemTemplate>
                <DataTemplate>
                    <Canvas>
                    <local:TaskListControl Canvas.Left="{Binding ListLeft}" 
                                           Canvas.Top="{Binding ListTop}" 
                                           Width="{Binding ListWidth}" 
                                           Height="{Binding ListHeight}"
                                           ListDetails="{Binding}"/>
                    </Canvas>    
                </DataTemplate>
            </ItemsControl.ItemTemplate>
        </ItemsControl>    

TaskListControl in turn declares and bind to it's ViewModel and I've also defined a dependency property for the ListDetails property.

The ListDetails property is not being set and if I remove the declarative reference to it's viewmodel the dependency property's callback does get fired.

Is there a conflict with declaratively binding to viewmodels and definig dependency properties?

I really like MVVM Light's blendability and want to perserve with this problem so any help would be apprectiated.

If you'd like to receive the source for my project then please ask

© Stack Overflow or respective owner

Related posts about mvvm

Related posts about light