Bing Maps (Silverlight) maps - specifying canvas to be at foreground through XAML

空扰寡人 提交于 2020-01-06 04:01:27

问题


Below is the XAML code i have for a Bing Maps Silverlight weather related implementation.

Here is what i am trying to do:

  1. Have a bing maps with several (over 100) pushpins- on mouseover - show a contentpopup (canvas=myPopup) below. Simple enough.
  2. Everything works fine - however, when mypopup displays on mouseover, it is not on the foreground (the other pins appear on top of the contentpopup) - hence making it not very readable.

Question:

How do i specifiy the myPopup canvas specified in XAML below to always appear in the foreground, i.e. top most of the Bing Maps silverlight control when a user views it on mouseover.

Thanks!


<Grid x:Name="LayoutRoot" Background="White">
    <m:Map x:Name="GlobalMap" Mode="Road"  Center="15,7" ZoomLevel="2" CredentialsProvider="{StaticResource MyCredentials}" Margin="-70,-40,-100,-72">

        <m:MapLayer x:Name="myLayer">
            <Canvas x:Name="myPopup" Visibility="Collapsed" Opacity="1">
                <Rectangle x:Name="myPopupRectangle" Fill="White" Canvas.Left="0" Canvas.Top="0" Height="100" 
                           Width="100" RadiusX="15" RadiusY="15"/>
                <StackPanel Canvas.Left="8" Canvas.Top="8">
                    <TextBlock x:Name="myPopupTexts" FontSize="5" Width="100">
                    </TextBlock>

                </StackPanel>
            </Canvas>
        </m:MapLayer>
    </m:Map>
</Grid>

回答1:


Try adding Canvas.ZIndex to the MapLayer element, give it a large value like 200 or add your push pins to another MapLayer (rather than adding the pins directly to the map) that appears ahead of this popup layer in document order.




回答2:


I did something similar to this, but took a different approach. What I did was create a custom pushpin template and create a PopUp within the template.

When the user hovers over the pushpin, the popup is displayed. Using the PopUp will solve your problem, since the control will automatically position it on top of everything. Try wrapping the Canvas in a PopPup and see if that works.

hth



来源:https://stackoverflow.com/questions/4299426/bing-maps-silverlight-maps-specifying-canvas-to-be-at-foreground-through-xam

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!