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 5967291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:55:22+00:00 2026-05-22T19:55:22+00:00

I am data binding some pushpins to a MapLayer. They display fine, but when

  • 0

I am data binding some pushpins to a MapLayer. They display fine, but when I use the relaycommand to pass the eventargs from the mouse leftbuttonUp, the object sources is an elipse. I have used this method on a MapPolygon and picked up the information I wanted from the object.

Maybe I am aproaching this badly as I am new to mvvm, so please let me know!

This works for my MapPolygons (vm references the namespace of my extendedMapPolygon class)

    <DataTemplate x:Name="polyTemplate">
        <vm:extendedMapPolygon cName="{Binding _cName}" Locations="{Binding _Locations}" />
    </DataTemplate>

Here is the XAML in the MapLayer

    <m:MapItemsControl ItemTemplate="{StaticResource polyTemplate}" ItemsSource="{Binding  Path=_PolyforDisplay, Mode=TwoWay}"  >
        <i:Interaction.Triggers>
               <i:EventTrigger EventName="MouseLeftButtonUp">
                    <cmd:EventToCommand Command="{Binding Path=PolySelCommand}" PassEventArgsToCommand="True" ></cmd:EventToCommand>
               </i:EventTrigger>
        </i:Interaction.Triggers>
    </m:MapItemsControl>

In my viewModel constructor

PolySelCommand = new RelayCommand<MouseButtonEventArgs>(PolySelCommandExecute);

and finally the actual command

        public RelayCommand<MouseButtonEventArgs> PolySelCommand { get; set; }
    private void PolySelCommandExecute(MouseButtonEventArgs cmp)
    {
        Polygon poly = cmp.OriginalSource as Polygon;
        extendedMapPolygon ePoly = poly.Parent as extendedMapPolygon;
        _MapPolygonSelected =  ePoly.cName;
    }

(I put this here to show both the method I am currently using and in the hope it may be of some use to others!)

When I try the same thing with a Pushpin however, the cmp.OriginalSource is an ellipse and I can not seem to get anything else passed through.

My Pushpin code (I am just using the Pushpins in the MapControl in this code)

    <DataTemplate x:Name="ppTemplate">
        <m:Pushpin ToolTipService.ToolTip="{Binding _psName}" Location="{Binding _Location}" />
    </DataTemplate>

    <m:MapItemsControl ItemTemplate="{StaticResource ppTemplate}" ItemsSource="{Binding Path=_PinsforDisplay, Mode=TwoWay}">
        <i:Interaction.Triggers>
             <i:EventTrigger EventName="MouseLeftButtonUp">
                  <cmd:EventToCommand Command="{Binding Path=pinSelCommand}" PassEventArgsToCommand="True" ></cmd:EventToCommand>
             </i:EventTrigger>
        </i:Interaction.Triggers>
    </m:MapItemsControl>

Should I be using the command parameter? Or someother way of passing text through to my viewmodel when I click on the pushpin, which is what I actually want.

  • 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-22T19:55:23+00:00Added an answer on May 22, 2026 at 7:55 pm

    I’d move the trigger to the pushpin element.

        <DataTemplate x:Name="ppTemplate">
            <m:Pushpin ToolTipService.ToolTip="{Binding _psName}" Location="{Binding _Location}">
                 <i:Interaction.Triggers>
                        <i:EventTrigger EventName="MouseEnter">
                            <i:Interaction.Triggers>
                                <i:EventTrigger EventName="MouseLeftButtonUp">
                                    <cmd:EventToCommand Command="{Binding Path=DataContext.pinSelCommand}" 
                                                        CommandParameter="{Binding WhateverPropertyHasTheText" />
                                </i:EventTrigger>
                            </i:Interaction.Triggers>
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
            </m:Pushpin>
        </DataTemplate>
    

    Notice I’m passing as a command parameter whatever property you want to send from the objects in _PinsForDisplay. Also, the binding for the command changed slightly, as the binding is different from inside a datatemplate.

    And then you’d have to change your RelayCommand on the viewmodel to RelayCommand.

    I didn’t test this code, but something very similar is working for me so hopefully it can lead you toward a solution.

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

Sidebar

Related Questions

I am binding some data to control, but want to limit the number of
I've been doing some Web-Projects lately that rely on heavy Data-Binding and have been
Here is some XAML <HierarchicalDataTemplate DataType={x:Type data:FolderEntity} ItemsSource={Binding Path=FolderEntities,UpdateSourceTrigger=PropertyChanged}> <Label Content={Binding FolderName}/> </HierarchicalDataTemplate> <TreeView/>
In ASP.NET, I am exporting some data to Excel by simply binding a DataSet
When databinding my xaml to some data I often use the get part of
I want to use data binding with an XML document to populate a simple
I'm working through the Data Binding chapter in Pro WPF in C# 2008. They
I am looking into binding some data. What method of output would be better.
I have a gridview using object datasource for data binding. Everything is working fine
When data binding two elements together, how can I include the binding information AND

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.