How can I access, using C#, a public instance method declared in App.xaml.cs?
Access of the controls from within the same assembly is hence allowed. If you want to access a control on a wpf form from another assembly you have to use the modifier attribute x:FieldModifier="public" or use the method proposed by Jean.
xaml. cs is the code-behind page for MainPage. xaml. It's where you add your app logic and event handlers. Together these two files define a new class called MainPage , which inherits from Page, in the HelloWorld namespace.
Solution 1Go to add new items -> online templates and then choose 'Silverlight Application Class'. This will add a new app. xaml for you.
((App)Application.Current).YourMethod ....
Have you considered to create a separate class to hold your application wide methods (eg. AppState.cs)?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With