0

Following This Sample I am hoping to be able a real MVVM pattern from the tutorial but based on my understanding the application is missing the Model and View classes!

I have the MapViewModel.cs like this

 public class MapViewModel
    {
        public MapViewModel(){ }

        private Map _map = new Map(Basemap.CreateStreets());
        public Map Map
        {
            get { return _map; }
            set { _map = value;  }
        }

    }

and the MainWindow.xaml

<Window.Resources>
    <local:MapViewModel x:Key="MapViewModel" />
</Window.Resources>
<Grid>
    <esri:MapView Map="{Binding Map, Source={StaticResource MapViewModel}}" />
</Grid>

but whre are the "MapView and "MapModel classes? Can you please help me to extracts and create those classes from the MapViewModel and create a real MVVM model?

1

In this context, your Xaml behaves as a View tier which contains the MapView. You can think that the MapView is the view for the Map which is the Model and you use MapViewModel to clue them together.

Remember to implement property changed to your view model as well so later if you change the Map-model, the change gets propagated to the MapView-view.

Hopefully, that wasn't too confusing :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.