I'm currently using MVVMLight for my WP7 app and have found that the datacontext for an EventToCommand is always the page datacontext. I'm also using the phon开发者_C百科e.codeplex.com panorama control and had set the datacontext for each PanoramaItem to a different ViewModel but this datacontext is ignored and the page data context is used instead.
Anyone know why?
This should not be the case. After working intensively for 2 weeks on a WP7 application with MVVM light, i can confirm that the DataContext should be set correctly. It is possible that
a) the CodePlex panorama control does something weird. That would be surprising but I cannot exclude it, having never used this control.
b) your DataContext has been overwritten somewhere in your DataTemplate. Blend does that sometimes. Make sure that this is not the case.
If the problem persists, send me a repro (small extract of the code where the problem is visible) and I will check it out.
Thanks, Laurent
精彩评论