views:

19

answers:

1

I have two pages in WPF. Page A contains all of my code. Page B is meant to be like a control panel where I click buttons to operate window A.

The problem I am running into is I want to make function calls from B to A but I am getting a scope error.

In the below code I am getting the error specifically on the axFlash object.

namespace GoogleMapsFlashInWpf

{

public partial class ButtonPage : Page
{
    public ButtonPage()
    {
        InitializeComponent();
    }

    private void ClearMarkersButton(object sender, RoutedEventArgs e)
    {
        StackTrace asdf = new StackTrace();
        Console.WriteLine(asdf.GetFrame(0).GetMethod().Name.ToString() + " called from " + asdf.GetFrame(1).GetMethod().Name.ToString());
        XElement call = new XElement("invoke",
                new XAttribute("name", "clearMarkers"),
                new XAttribute("returntype", "xml"));
        try
        {

            axFlash.CallFunction(call.ToString(SaveOptions.DisableFormatting));
        }
        catch (Exception error)
        {
            Console.WriteLine(error.ToString());
        }

    }//end ClearMarkersButton
}

}

A: 

The error is right...the axFlash object doesn't exist in the scope of that method. You need to make axFlash an object defined under ButtonPage class. Then, you must make sure that axFlash object is set before you wish to call that function.

sbenderli
I would ideally like to just call the method located in window A. How would I do this?
Paul
To do that, you should first add a definition of window A in window B. Then, in window B, within your code, call Parent.axFlash.CallFunction.Note that axFlash must be visible to the outside world.
sbenderli