Disable Drag e Drop of elements in the legend

Sep 20, 2013 at 9:51 AM
Hi all,
we are building an app in wich we want that the legend control cannot accept data that the user drags onto it.
Moreover we would like to in general disable drag & drop of legend elements, and to block (in example) moving from one Group to another in my legend.

There is LegendItem.IsDragable Property, I set it to "false", and despite this I'm able to drag a legend element to a new position in the legend. Is it normal?

Below some code.

Thank you very much
Private Sub Inizializzamappa() 
        'imposto la cultura inglese-americana, per compatibilità con le componenti spaziali 
        Thread.CurrentThread.CurrentUICulture = New System.Globalization.CultureInfo("en-US") 

        Dim esrsistring As String = "PROJCS[""Popular Visualisation CRS / Mercator"",GEOGCS[""Popular Visualisation                         CRS"",DATUM[""D_Popular_Visualisation_Datum"",SPHEROID[""Popular_Visualisation_Sphere"",6378137,0]],PRIMEM[""Greenwich"",0],UNIT[""Degree"",0.017453292519943295]],PROJECTION[""Mercator""],PARAMETER[""central_meridian"",0],PARAMETER[""scale_factor"",1],PARAMETER[""false_easting"",0],PARAMETER[""false_northing"",0],UNIT[""Meter"",1]]" 

        p_map = DotSpatial.Projections.ProjectionInfo.FromEsriString(esrsistring) 

        Me.lblproiezione.Text = Map2.Projection.Transform.Name 

        'inizializzo il layer poligoni 
        'inizializzazione poligoni 
        polyfs = New FeatureSet(FeatureType.Polygon) 
        polyfs.Name = "poly" 
        'polyfs.Projection = DotSpatial.Projections.KnownCoordinateSystems.Geographic.World.WGS1984 
        polyfs.Projection = Map2.Projection 

        pointfs = New FeatureSet(FeatureType.Point) 
        pointfs.Name = "Punti" 
        pointfs.Projection = Map2.Projection 

        Call ModificaMenuMappa() 

        codapolyfs = New FeatureSet(FeatureType.Polygon) 
        codapolyfs.Name = "codapoly" 
        codapolyfs.Projection = Map2.Projection 

        codaPointfs = New FeatureSet(FeatureType.Point) 
        codaPointfs.Name = "codaPoint" 
        codaPointfs.Projection = Map2.Projection 

        codaLineFs = New FeatureSet(FeatureType.Line) 
        codaLineFs.Name = "codalinee" 
        codaLineFs.Projection = Map2.Projection 

        'creo un gruppo 
        laygroupMappaBackGround.LegendText = "Backgroud image"  '"Immagine di sfondo" 
        laygroupMappaBackGround.Projection = Map2.Projection 
        AddHandler laygroupMappaBackGround.LayerRemoved, AddressOf laygroupMappaBackGround_Removeitem 
        laygroupMappaBackGround.IsDragable = False 

        laygroupShapeBackGround.LegendText = "Background map" '"Mappa di sfondo" 
        laygroupShapeBackGround.Projection = Map2.Projection 
        AddHandler laygroupShapeBackGround.LayerRemoved, AddressOf laygroupShapeBackGround_Removeitem 
        laygroupShapeBackGround.IsDragable = False 

        layAltroGroup.LegendText = "More" '"Altro" 
        layAltroGroup.Projection = Map2.Projection 
        AddHandler layAltroGroup.LayerRemoved, AddressOf layAltroGroup_Removeitem 
        AddHandler layAltroGroup.LayerAdded, AddressOf layAltroGroup_LayerAdded 
        layAltroGroup.IsDragable = False 

        layPolyGroup.LegendText = "Route and footprint" '"poligoni" 
        layPolyGroup.Projection = Map2.Projection 
        layPolyGroup.IsDragable = False 

        Map2.Projection = p_map 
        Map2.MapFrame.Projection = p_map 
        Map2.AllowDrop = False 
        Legend1.AllowDrop = False 
    End Sub
Dec 18, 2013 at 8:11 PM
Edited Dec 18, 2013 at 8:11 PM
just override the base legend control, here you go:
public class RestrictedLegend : Legend
    protected override void OnMouseMove(MouseEventArgs e)
        // remove any mouse movement events from the legend