c# - 如何更改 BingMaps for Silverlight 中自定义图钉内元素的大小

标签 c# silverlight bing-maps

我有一个包含椭圆的自定义图钉,我想在后面的 C# 代码中以编程方式更改其大小。我可以更改图钉大小,但这会影响它在 map 上的位置。

有没有办法直接通过渲染变换或直接更改椭圆的高度和宽度来处理椭圆?

这是 xaml:

<map:Pushpin Location="51.4,-0.2" >
    <map:Pushpin.Template>
        <ControlTemplate>
            <Ellipse Width="15" Height="15" Fill="Red" Opacity="0.7" Stroke="Black" StrokeThickness="2.5">
                 <Ellipse.RenderTransform>   
                     <TranslateTransform X="0" Y="18" />
                 </Ellipse.RenderTransform>
             </Ellipse>
         </ControlTemplate>
     </map:Pushpin.Template>
</map:Pushpin>

这是我目前使用的 C#,它改变了图钉大小(目前为随机数):

private void MapItemsSizeChange()
{
    Random rnd = new Random();
    ScaleTransform pin_st = new ScaleTransform();

    if (mainMap != null)
    {
        foreach (UIElement UI in mainMap.Children)
        {
            if (UI is Pushpin)
            {
                var pin = UI as Pushpin;

                if (pin != null)
                {
                    double x = rnd.Next(5, 20);
                    x = x / 10;

                    pin_st.ScaleX = x;
                    pin_st.ScaleY = x;

                    UI.RenderTransform = pin_st;
                }
            }
        }
    }
}

谢谢大家!

最佳答案

关于c# - 如何更改 BingMaps for Silverlight 中自定义图钉内元素的大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8805390/

相关文章:

c# - 使用 Canvas 矩形裁剪图像

c# - 路径作为类似于 Directory.GetFiles 的方法的模式匹配的一部分

c# - 如何检测鼠标是否直接在 WPF 中的对象类型上

c# - Windows Phone 8.1 (Silverlight) 消息框扩展功能

Silverlight:ItemsControl 中的最后一项

javascript - 获取事件点击时的纬度和经度 - Bing map 和 webv8

javascript - 移动 map 时,Bing map 信息框会移动 FireFox 和 Chrome 中的位置

c# - 偏移量 1049 处的无效请求 BLR - 函数 ROUNDDEC 未定义

c# - 将 map 显示为椭圆形

Silverlight MVVM 绑定(bind)和扩展类属性的使用