Working with Events of Popup XAML

Aug 6, 2008 at 10:39 AM
Hi,

Here is the code I am playing with to get the mangaed event for Find method to be called.

controller.Map.FindCompleted += new EventHandler<VIEWS.FindCompletedEventArgs>(findEventCompleted);
                FindOptions fndoptions = new FindOptions();
                fndoptions.UseDefaultDisambiguation = false;             
    
                controller.Map.Find("Food World", "Seattle,WA,US", fndoptions);               
               
My aim to call one managed method that takes care of results returned from Find Method
The method is not being called. am I missing something or am I going in wrong way.

Thanks in anticipation.

Thanks
Mohammed Idrees
Coordinator
Aug 6, 2008 at 4:20 PM
The included sample application actually handles this event. Have you had a chance to look at that?

The sample also shows how to handle pin click events. Check the CheckBox next to the From or Two text box in the Directions area of the sample and then click on a push pin. You'll see that the click is handled and information about the pin is placed into the From or To box.
Aug 18, 2008 at 10:59 AM
Thanks Jared. I got the solution to display the Silverlight Popup on OnClick event of the shapes.

My current scenario is to have the silverlight button in the popup xaml content and add the events to the button using managed code.

Thanks in anticipation well in advance.

Thanks
Mohammed Idrees
Aug 20, 2008 at 5:06 AM
Hi, Can anyone please guide as how we can have the buttons and its managed events in silverlight popup display.

I am trying to use popup.cs file(ShowPopup method) to add new button and its event('Click'). This is working fine for only one pushpin click. Once I come back to the map and click another pushpin to see its popup. I am getting an exception.

The code I added in the ShowPopup Method of popup.cs file is
  Button btnx = new Button();
                btnx.Click += new RoutedEventHandler(btnx_Click);
                btnx.Content = "Display Map after the click";
                pg.stackPanel.Width = 800;
                pg.stackPanel.Height = 640;
                pg.stackPanel.Children.Add(btnx);

The error I am getting once I click on any other pushpin after coming back from popup is
"unknown exception" at silverlightPopup.content.popup.ShowPopup(this); in popup.js.

Can anyone please suggest me the ways as how we can have the buttons in popup and its associated managed events.

Thanks in anticipation

Mohammed Idrees
Coordinator
Aug 21, 2008 at 1:18 PM
I believe this is the same issue as you're discussing in this thread: [discussion:32840]. Is that correct?

Just looking at the short code snippet I'd be careful that you're not trying to add btnx to the stack panel more than once. That seems to happen on every button click and I don't see where it gets removed. You can always tell Visual Studio to catch exceptions the moment they are thrown and this may keep the exception from bubbling up into JavaScript.

Again, if this is truly an issue with VIEWS you can open an issue in the issue tracker and attach sample code and steps to reproduce.

Regards,

Jared Bienz
Aug 21, 2008 at 2:31 PM
thanks Jared for the reply,

I used the basic available code and worked on the same.
To reproduce the same,
Just click(right click / left click) on the popup window. (even if the button is not available)
Comeback to the map and click any other pin, you will face the unknown exception

I am going to add the same repro steps in the issue tracker as well.

Thanks
Mohammed Idrees



Oct 28, 2008 at 9:31 PM
This is a bug.
It will trigger a mouse event which will cause exception "Operation is not valid due to the current state of the object".
You can avoid this by comment out  the following in the method "HidePopup()"

elem.SetStyleAttribute("visibility", "hidden");


Regards,

Feng Gu