Exemplo n.º 1
0
 /// <summary>
 /// Occurs when the value of the <see cref="ZoomLevel"/> property has changed.
 /// </summary>
 /// <param name="e">
 /// A <see cref="DependencyPropertyChangedEventArgs"/> containing event information.
 /// </param>
 protected virtual void OnZoomLevelChanged(DependencyPropertyChangedEventArgs e)
 {
     #if WIN_RT
     // The Win8 version of the map control does not allow Zoom Level to be data bound
     if (map != null)
     {
         map.ZoomLevel = PercentBingZoomConverter.PercentToMapLevel(ZoomLevel);
     }
     #endif
 }
Exemplo n.º 2
0
        protected override void OnApplyTemplate()
        #endif
        {
            base.OnApplyTemplate();

            map = GetTemplateChild(PartNames.Map) as Map;

            // Validate the template
            if (map == null)
            {
                throw new InvalidOperationException(string.Format("{0} template is invalid. A {1} named {2} must be supplied.", GetType().Name, typeof(Map).Name, PartNames.Map));
            }

            // Connect credentials
            #if WP7
            map.CredentialsProvider = credentials;
            #endif

            #if WP8
            if (credentials != null)
            {
                MapsSettings.ApplicationContext.ApplicationId       = credentials.ApplicationId;
                MapsSettings.ApplicationContext.AuthenticationToken = credentials.AuthenticationToken;
            }
            #endif

            #if WIN_RT
            map.Credentials = credentials;
            #endif

            // Update the margin
            UpdateMargin();

            // Connect data
            map.DataContext = arItems;
            #if WP8
            // We must use the toolkit to get the child map items controls and set their items source properly
            foreach (var itemsControl in MapExtensions.GetChildren(map).OfType <MapItemsControl>())
            {
                itemsControl.ItemsSource = arItems;
            }
            #endif

            #if WIN_RT
            // Set initial values for properties that can't be data bound in Windows 8
            map.Center    = Location;
            map.ZoomLevel = PercentBingZoomConverter.PercentToMapLevel(ZoomLevel);
            #endif
        }