Click here to Skip to main content
15,908,437 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I would like to know how to call the Main page of the Silverlight application without creating one.

Lets say I have the form it presses a button then create a class called daMaster and daMaster executes a method that calls another class called dams.

Then dams executes a method that wants to change a label on the MainPage.

If I use MainPage mp = new MainPage();, correct me if I'm wrong but does that not create a new instance of the page or does it retrieve(which i doubt)?
Posted

1 solution

The clue is in the word:

MainPage mp = new MainPage();

There are a number of ways to do this, but the best is to have your class throw an event, which it's parent can subscribe to, and throw it's own to pass it up to the form. That way, the form only subscribes to the event if it wants it's label changed, and is on the correct thread - which your class has no idea about. Best of all, your class does not have to know about either of the two classes above it. It definitely does not need to know about forms, unless there is something very wrong in your design.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900