图生活吧

博客园 首页 新随笔 联系 订阅 管理

在FeatureLayer的Initialized事件中,MapTip通过Template加载自定义的控件模板,然后创建一个Canvas承载MapTip,并添加到页面上。

Private Sub FeatureLayer_Initialized(ByVal sender As Object, ByVal e As EventArgs)
    Dim c As Canvas = New Canvas
    Dim mt As MapTip = New MapTip() With {.Template = CType(Application.Current.Resources("myMapTipTemplate"), ControlTemplate)}
    mt.GraphicsLayer = fl
    c.Children.Add(mt)
    LayoutRoot.Children.Add(c)
End Sub

 自定义的控件模板如下:

<ControlTemplate x:Key="myMapTipTemplate">
    <Grid>
        <StackPanel>
            <TextBlock Text="测试" />
        </StackPanel>
    </Grid>
</ControlTemplate>

 

posted on 2011-12-27 14:15  图生活吧  阅读(775)  评论(0编辑  收藏  举报