Pushpin resize binding zoomlevel

与世无争的帅哥 提交于 2019-12-12 18:46:54

问题


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



来源:https://stackoverflow.com/questions/17177352/pushpin-resize-binding-zoomlevel

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