Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Get Your Silverlight MainPage

0.00/5 (No votes)
9 May 2011 1  
Get access to your Silverlight MainPage object
If you ever need to access the MainPage object of your Silverlight application (from elsewhere in that application), simply do this where needed:

C#
MainPage mainPage = App.Current.RootVisual as MainPage;


Bonus Tip: Don't be hesitant to look at the code generated by Visual Studio. I found out wthat the RootVisual property represents the MainPage object and is set when the application is started. Once I discovered that, the rest was easy.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here