Cannot find a Resource with the Name/Key ViewerDataSource

959
0
03-01-2012 06:35 PM
Swani_Jesus_Captonsiluvairajan
New Contributor III
Iam trying to extend the Silverlight viewer Layout project.  When I try to data bind using a view model by setting the DataContext to the BlackBox.XAML 's LayoutRoot Grid, my data coontext is not recognized !

Well, so I decided to run the sample without any modifications using the sample "ViewerDataSource" BUT I just changed the d:DataContext to just DataContext basically removing the 'mc:Ignorable' attribute and the viewer crashed saying "Cannot find a Resource with the Name/Key ViewerDataSource"  here is the line I changed 

"<Grid x:Name="LayoutRoot"  DataContext="{Binding Source={StaticResource ViewerDataSource}}">"

Why is the viewer not ale to find the data context resource ? How am I suppose to use my ViewModel etc if the sample datasource provided itself doesn't work?


*********************EDIT*****************

OK.  I get it now.  Layout Project is only for making changes to layout.  I just created a Grid element [<Grid x:Name="CIMSViewerLayout" Grid.Column="2" >] to the right side of the Map, similar to TOC that appears on the left side in BalckBox.XAML template.  This basically created an empty space for me where I can pop in my User Control from my AddIn Project as below.

Then in my Addin project I used

private QueryView QueryView = QueryView ?? new QueryView();
(MapApplication.Current.FindObjectInLayout("CIMSViewerLayout") as Grid).Children.Add(QueryView);

Here QueryView  = QueryView.XAML is the User control that contains all my login etc and has the dataContext that references my ViewModel.  All works beautifuly now.


Any help would be appreciated
Thanks in advance,
Capton.
0 Kudos
0 Replies