Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 786997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T21:07:55+00:00 2026-05-14T21:07:55+00:00

I was able to make my silverlight Bing map accepts Mousclicks and converts them

  • 0

I was able to make my silverlight Bing map accepts Mousclicks and converts them to Pushpins in C#. Now I want to show a text next to the PushPin as a description that appears when the mouse goes over the pin , I have no clue how to do that. What are the methods that enable me to do this thing?

This is the C# code :

public partial class MainPage : UserControl

{
private MapLayer m_PushpinLayer;

public MainPage()
{
    InitializeComponent();
    base.Loaded += OnLoaded;
}

private void OnLoaded(object sender, RoutedEventArgs e)
{
    base.Loaded -= OnLoaded;

m_PushpinLayer = new MapLayer();
x_Map.Children.Add(m_PushpinLayer);
    x_Map.MouseClick += OnMouseClick;
}

private void AddPushpin(double latitude, double longitude)
{
    Pushpin pushpin = new Pushpin();
    pushpin.MouseEnter += OnMouseEnter;
    pushpin.MouseLeave += OnMouseLeave;
    m_PushpinLayer.AddChild(pushpin, new Location(latitude, longitude), PositionOrigin.BottomCenter);
}

private void OnMouseClick(object sender, MapMouseEventArgs e)
{
    Point clickLocation = e.ViewportPoint;
    Location location = x_Map.ViewportPointToLocation(clickLocation);
    AddPushpin(location.Latitude, location.Longitude);
}

private void OnMouseLeave(object sender, MouseEventArgs e)
{
    Pushpin pushpin = sender as Pushpin;

    // remove the pushpin transform when mouse leaves
    pushpin.RenderTransform = null;
}

private void OnMouseEnter(object sender, MouseEventArgs e)
{
    Pushpin pushpin = sender as Pushpin;

    // scaling will shrink (less than 1) or enlarge (greater than 1) source element
    ScaleTransform st = new ScaleTransform();
    st.ScaleX = 1.4;
    st.ScaleY = 1.4;

    // set center of scaling to center of pushpin
    st.CenterX = (pushpin as FrameworkElement).Height / 2;
    st.CenterY = (pushpin as FrameworkElement).Height / 2;

    pushpin.RenderTransform = st;
}

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T21:07:55+00:00Added an answer on May 14, 2026 at 9:07 pm

    You have 2 ways to go:

    (1) Create any UIElement to pass into PushPinLayer.AddChild. The AddChild method will accept and any UIElement, such as this Grid containing an Image and a TextBlock:

    MapLayer m_PushpinLayer = new MapLayer(); 
    Your_Map.Children.Add(m_PushpinLayer);
    Image image = new Image(); 
    image.Source = ResourceFile.GetBitmap("Images/Pushpin.png", From.This); 
    TextBlock textBlock = new TextBlock();
    textBlock.Text = "My Pushpin";
    Grid grid = new Grid();
    grid.Children.Add(image);
    grid.Children.Add(textBlock);
    
    m_PushpinLayer.AddChild(grid, 
        new Microsoft.Maps.MapControl.Location(42.658, -71.137),   
            PositionOrigin.Center);
    

    (2) Create a native PushPin object to pass into PushpinLayer.AddChild, but first set it’s Template property. Note that PushPin’s are ContentControls, and have a Template property that can be set from a Resource defined in XAML:

    MapLayer m_PushpinLayer = new MapLayer(); 
    Your_Map.Children.Add(m_PushpinLayer); 
    Pushpin pushpin = new Pushpin(); 
    pushpin.Template = Application.Current.Resources["PushPinTemplate"]   
        as (ControlTemplate); 
    m_PushpinLayer.AddChild(pushpin, 
        new Microsoft.Maps.MapControl.Location(42.658, -71.137),   
            PositionOrigin.Center);
    

    …

    <ResourceDictionary 
        xmlns="http://schemas.microsoft.com/client/2007" 
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    > 
        <ControlTemplate x:Key="PushPinTemplate"> 
            <Grid> 
                <Image Source="Images/Pushpin.png" /> 
                <TextBlock Text="My Pushpin" /> 
            </Grid> 
        </ControlTemplate> 
    </ResourceDictionary>
    

    Good luck,
    Jim McCurdy

    Face To Face Software, and YinYangMoney

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We were able to solve a high CPU usage problem by taking advantage of
I'm working on a custom control for Silverlight 4 in VS2010 and Expression Blend
I'm using the AutoCompleteBox of the silverlight toolkit in my WP7 application. When the
We're currently using the Silverlight VideoSink to capture video from users' local webcams, kinda
In SL4, I am finding it oddly difficult to figure out how to make
I am working on a web application that is a pretty simple and straightforward
I have a application written in C#, installed as a [WCF] windows service, which
We have a requirement to prevent saving additional copies of PDFs that exist out
I have a small problem. I am trying to check to see if status's
I am doing a practice to understand read and write zip files in java.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.