Being able to interact with the layers in the map is a very important capability that your users will expect. Otherwise, the map is just a pretty picture. To provide this capability in a non-MVVM app would simply require adding a click event to the code-behind file of MainWindow.cs
. Another feature that your user might expect is the ability to see coordinates on the map as they move the mouse. But how do we accomplish this with MVVM in such a way that we can move our code from MainWindow.cs
to another place?
Well, you already know the answer. We create a UserControl
task with ViewModel
and have it display the coordinates in the XAML code of UserControl
. Let's implement this:
Create a new ArcGIS Runtime project. In this example, we're going to name it
Chapter6
. Copy the following folders:Behavior
,Models
,Services
, andViewModels
. Install MVVM Light andJson.Net
, and add a reference toSystem.Windows.Interactivity
(4.5). When you install MVVM Light, aViewModel
directory...