Select to view content in your preferred language

GraphicsLayer data binding issue

3548
11
08-25-2011 09:23 AM
MichaelCheng
Emerging Contributor
I am writing a POC to integrate with our current app, which builds on MVVM pattern.  I'm trying to bind a collection of "Graphic" objects to either Graphics or GraphicsSource property of a GraphicsLayer.  I am using Silverlight4 and that should allow DependencyProperties to allow binding in DependencyObjects as long as it is contained in a FrameworkElement, which in this case, is the Map object.  However I am not having any success.  I can; however, bind Layers to a collection of Layer objects and that'd trickle down, but I am hoping I can have better control and only bind where need be.  Is this possible with your control?  Or am I missing something?  Thank you.
0 Kudos
11 Replies
SANDEEPMEHNDIRATTA
Emerging Contributor
Any update, I am having same problem
0 Kudos
TraceyRichvalsky
Emerging Contributor
My co-worker helped me fix this.  Instead of defining the view model in your <view>.xaml file, define it in <app>.xaml.  I forget the entire explanation he had for this (and he has now moved to Hawaii for a year!) but it had to do with the binding not being able to be accessed throughout the code.  So, in the example ESRI gave:

They have this in their XAML code:
        <Grid.Resources>
            <local:Customers x:Key="customers" />
        </Grid.Resources>

Move it to the App.xaml file:
    <Application.Resources>
            <local:Customers x:Key="customers" />
    </Application.Resources>

Hope that helps you!  It worked for me.
0 Kudos