I'm using WinRT with bing maps and i'm trying to set (programmatically) the RenderTransform value of my pushpin when zooming on map. I tried this Solution but seems that the Windows 8 controls do not support binding to the ZoomLevel property. does anyone have any either workaround or working example ? Thankyou in advance
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
I post here an example that can be used from others if needed. Exploiting your suggestion of using the "ViewChanged" event I wrote this code snippet:
private double Interpolate(double x0, double y0, double x1, double y1, double x)
{
return y0 * (x - x1) / (x0 - x1) + y1 * (x - x0) / (x1 - x0);
}
private void mapZoom_Event(object sender, ViewChangedEventArgs e)
{
double scale;
foreach (Pushpin currentPin in currentPins)
{
double zoom = Map.ZoomLevel;
scale = interpolate(10, 1 / 2, 18, 3, zoom);
if (scale < 1)
scale = 1;
ScaleTransform pushpinsScaleTransform = new ScaleTransform()
{
ScaleX = scale,
ScaleY = scale
};
currentPin.RenderTransform = pushpinsScaleTransform;
}
}
where currentPins is an IEnumerable that are in the Map. The Interpolate method is a simple Lienar function where it should linearly scale the size of your pushpin.
回答2:
OK resolved: I just associate the ViewChanged event that update also the Zoom Level and in this function I create the RenderTransform property and asspciate it to my Pushpin