DrawStatusChanged not firing

03-29-2017 07:46 AM
Regular Contributor II

When I only have an ArcGISTiledLayer loaded, the MapView.DrawStatusChanged event fires exactly as expected.  However, when I add layers from a MobileMapPackage, it doesn't want to fire properly at all.  Is this a known (WPF) issue? [NavigationCompleted fires OK.]

Tags (1)
0 Kudos
2 Replies
Esri Regular Contributor

However, when I add layers from a MobileMapPackage, it doesn't want to fire properly at all.

Are you removing the layer from the MobileMapPackage.Map before adding to your MapView.Map? It might be that you are getting "Object already owned" error and the layer from mobile map package is never added to the map?

If you would like to know the state for each layer added, you can use LayerViewStateChanged, it also has Error property that you can check.

You can try the following code which reports status from both events. Load button will add layers from mobile map package. I assume, this is what you're trying to do?

        <esri:MapView x:Name="MyMapView"
                <esri:ArcGISMapImageLayer Source="http://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer" />
        <StackPanel VerticalAlignment="Top"
            <Button Content="Load"
                    Click="Button_Click" />
            <ListView x:Name="Status" />
        public MainWindow()
            Status.ItemsSource = _status;
        private ObservableCollection<string> _status = new ObservableCollection<string>();
        private void MyMapView_DrawStatusChanged(object sender, Esri.ArcGISRuntime.UI.DrawStatusChangedEventArgs e)

        private void MyMapView_LayerViewStateChanged(object sender, LayerViewStateChangedEventArgs e)

        private async void Button_Click(object sender, RoutedEventArgs e)
            var mmpk = await MobileMapPackage.OpenAsync(@"C:\Temp\sanfrancisco.mmpk");
            foreach (var layer in mmpk.Maps[0].Basemap.BaseLayers.ToList())
            foreach (var layer in mmpk.Maps[0].OperationalLayers.ToList())
0 Kudos
Regular Contributor II

The "Object not owned" error actually crashes the app.  I ran into that long ago.  However, if a draw error on a layer is not raising an unhandled exception, but is causing DrawStatusChanged not to fire, that could be the problem.  I'll look into that, and thanks for the example.

I do know that some of the MMPKs I've created cause problems in Runtime, especially if they were imported into Pro from an ArcMap MXD.  For example, one layer causes the app to crash when visibility is turned off!  I'm working on recreating some of my maps from scratch in Pro to see if that makes a difference.

0 Kudos