tags:

views:

242

answers:

2

How can I access, using C#, a public instance method declared in App.xaml.cs?

+2  A: 
((App)Application.Current).YourMethod ....
Akash Kava
It works, but I don't understand. If Application.Current == App, and they are the same type, how is this type-cast working? Thanks
Gustavo Cavalcanti
Application is System.Windows.Application where else App is inside your project derived from Application, Application.Current is of type Application, not App.
Akash Kava
A: 

Have you considered to create a separate class to hold your application wide methods (eg. AppState.cs)?

xamlgeek
This is a better approach, but I wanted to know how to see the stuff declared in App.xaml.cs. Thanks.
Gustavo Cavalcanti