gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 18:40:06 25 4
gpt4 key购买 nike

我有一个包含椭圆的自定义图钉,我想在后面的 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com