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
}
}
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.
精彩评论