Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ViewModel : INotifyPropertyChanged
- {
- private Model myModel = null;
- private MapView mapView = null;
- public event PropertyChangedEventHandler PropertyChanged;
- public ViewModel()
- {
- var URI = "D:/GIS/Runtime/Tutorial/VanSchools.tpk";
- ArcGISLocalTiledLayer localTiledLayer = new ArcGISLocalTiledLayer(URI);
- localTiledLayer.ID = "SF Basemap";
- localTiledLayer.InitializeAsync();
- this.mapView.Map.Layers.Add(localTiledLayer);
- }
- public string TilePackage
- {
- get { return this.myModel.TilePackage; }
- set
- {
- this.myModel.TilePackage = value;
- }
- }
- public class Model
- {
- private string tilePackage = "";
- public Model() { }
- public string TilePackage
- {
- get { return this.tilePackage; }
- set
- {
- if (value != this.tilePackage)
- {
- this.tilePackage = value;
- }
- }
- }
- <Window x:Class="SimpleMVVM.MainWindow"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013"
- xmlns:local="clr-namespace:SimpleMVVM"
- mc:Ignorable="d"
- Title="MainWindow" Height="350" Width="525">
- <Window.Resources>
- <local:ViewModel x:Key="VM"/>
- </Window.Resources>
- <Grid DataContext="{StaticResource VM}">
- <Grid.RowDefinitions>
- <RowDefinition Height="400" />
- <RowDefinition Height="200" />
- </Grid.RowDefinitions>
- <esri:MapView x:Name="MyMapView" Grid.Row="0"
- LayerLoaded="MyMapView_LayerLoaded" >
- <esri:Map> </esri:Map>
- </esri:MapView>
- </Grid>
- </Window>
- public partial class MainWindow : Window
- {
- public MainWindow()
- {
- InitializeComponent();
- }
- private void MyMapView_LayerLoaded(object sender, LayerLoadedEventArgs e)
- {
- if (e.LoadError == null)
- return;
- Debug.WriteLine(string.Format("Error while loading layer : {0} - {1}", e.Layer.ID, e.LoadError.Message));
- }
- }
Add Comment
Please, Sign In to add comment