Select to view content in your preferred language

Map can't be dragged in the ListBox

798
4
05-26-2010 11:40 PM
hunterruan
Emerging Contributor
I have a listbox to show the items with maps, but I can't drag the map by the mouse.
What can I do if I want to control the map by mouse.

For example:
<Grid x:Name="LayoutRoot">
        <ListBox Width="600" Height="400"  Margin="0,5,0,10">
            <esri:Map x:Name="LocalMap" Width="600" Height="400" >
                <esri:ArcGISTiledMapServiceLayer ID="MyLayer" 
                Url="http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer" />
            </esri:Map>
        </ListBox>
    </Grid>
0 Kudos
4 Replies
dotMorten_esri
Esri Notable Contributor
The listbox is cancelling the mouse events, preventing the map from receiving these events. Unfortunately there's not much the map can do to prevent this.
0 Kudos
hunterruan
Emerging Contributor
Ok. Thanks for your reply.
0 Kudos
DominiqueBroux
Esri Frequent Contributor
It looks like by using the ScrollableMap sample, I posted a few days ago (http://resources.esri.com/arcgisserver/apis/silverlight/index.cfm?fa=codeGalleryDetails&scriptID=169...), it should work inside a listbox (even without using the scrollviewer capabilities).

Without scrollviewer for the item:
<ListBox Margin="0,5,0,10">
    <local:ScrollableMap>
        <esri:Map x:Name="LocalMap" Width="600" Height="400" >
            <esri:ArcGISTiledMapServiceLayer ID="MyLayer" 
                Url="http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer" />
        </esri:Map>
    <local:ScrollableMap>
</ListBox> 


With a scrollviewer for panning the map:
<ListBox Margin="0,5,0,10">
   <ScrollViewer ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto">
    <local:ScrollableMap>
        <esri:Map x:Name="LocalMap" Width="600" Height="400" >
            <esri:ArcGISTiledMapServiceLayer ID="MyLayer" 
                Url="http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer" />
        </esri:Map>
    <local:ScrollableMap>
 </ScrollViewer>
</ListBox> 
0 Kudos
hunterruan
Emerging Contributor
It looks like by using the ScrollableMap sample, I posted a few days ago (http://resources.esri.com/arcgisserver/apis/silverlight/index.cfm?fa=codeGalleryDetails&scriptID=169...), it should work inside a listbox (even without using the scrollviewer capabilities).

Without scrollviewer for the item:
<ListBox Margin="0,5,0,10">
    <local:ScrollableMap>
        <esri:Map x:Name="LocalMap" Width="600" Height="400" >
            <esri:ArcGISTiledMapServiceLayer ID="MyLayer" 
                Url="http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer" />
        </esri:Map>
    <local:ScrollableMap>
</ListBox> 


With a scrollviewer for panning the map:
<ListBox Margin="0,5,0,10">
   <ScrollViewer ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto">
    <local:ScrollableMap>
        <esri:Map x:Name="LocalMap" Width="600" Height="400" >
            <esri:ArcGISTiledMapServiceLayer ID="MyLayer" 
                Url="http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer" />
        </esri:Map>
    <local:ScrollableMap>
 </ScrollViewer>
</ListBox> 


I have test it successfully. Thank you very much.
0 Kudos