DropInfo.TargetModel is null in 2.3

105
3
Jump to solution
05-17-2019 04:14 PM
Highlighted
Occasional Contributor II

In 2.3 something went wrong. TargetModel is null in DropInfo that passed to OnDrop method of a drop handler. It makes it impossible to determine where I drop my object. I should perform drop on MapView only. In 2.2 TargetModel contained that MapView when I dragging an object over it.

Is it a bug or there is API to specify where it is valid to drop an object?

Tags (1)
Reply
0 Kudos
1 Solution

Accepted Solutions
Highlighted
Esri Regular Contributor

Hi Max

If you drop into a pane in Pro that holds a MapView, it will be an IMapPane.  From this, you can get the MapView.

This works even if you drop into a Pane that is not the active one (gray on the tab name).

Thanks

Uma

View solution in original post

Reply
0 Kudos
3 Replies
Highlighted
Esri Regular Contributor

Hi Max,

There was an issue with the sequence of how custom drop handlers were being evaluated in Pro 2.2 on drag drop and that was fixed in 2.3. Because custom handlers are now evaluated first, the TargetModel property cannot always be guaranteed to be populated. Instead, please use this code snippet below: We will be updating the relevant samples for 2.4.

public override void OnDrop(DropInfo dropInfo)
{

#region Implement Your OnDrop Here
if (FrameworkApplication.Panes.ActivePane is IMapPane)
{
//a drag is being made on the active map
var view = ((IMapPane)FrameworkApplication.Panes.ActivePane).MapView;
// globe or local
if (view.ViewingMode == MapViewingMode.SceneGlobal ||
view.ViewingMode == MapViewingMode.SceneLocal)
{
//we are in 3D
OnDrop3D(dropInfo);
}
else
{
//we are in 2D
OnDrop2D(dropInfo);
}
}
#endregion

dropInfo.Handled = true;
}

Thanks

Uma

Reply
0 Kudos
Highlighted
Occasional Contributor II

Hi Uma,

FrameworkApplication.Panes.ActivePane is the same thing as drop target? I think no. At now I use VisualTarget to determine where I'm dropping my object:

        private static bool IsOverMapView(DropInfo dropInfo)
{
if (dropInfo == null)
return false;

if (dropInfo.TargetModel is MapView)
return true;

var visualTarget = dropInfo.VisualTarget;
if (visualTarget == null)
return false;

// TODO: seems there is a bug in ArcGIS Pro SDK 2.3 with TargetModel is null, so this is a workaround
return visualTarget.GetType().Name == "MapPaneView";
}
Reply
0 Kudos
Highlighted
Esri Regular Contributor

Hi Max

If you drop into a pane in Pro that holds a MapView, it will be an IMapPane.  From this, you can get the MapView.

This works even if you drop into a Pane that is not the active one (gray on the tab name).

Thanks

Uma

View solution in original post

Reply
0 Kudos