Reputation: 10659
How can I access, using C#, a public instance method declared in App.xaml.cs?
Upvotes: 29
Views: 22507
Reputation: 2523
You can also add a static property in your App
class with new
modifier like so:
public static new App Current => Application.Current as App;
This way you can access your method like so:
App.Current.YourMethod()
Check this answer about new modifier on SO.
Upvotes: 0
Reputation: 1993
Have you considered to create a separate class to hold your application wide methods (eg. AppState.cs)?
Upvotes: 4