Answer the question
In order to leave comments, you need to log in
How to change button text from another class in Xamarin.IOS?
There are 2 classes. It is necessary to change the Title of the button located in another class from the main class. The problem is that the button was created by the constructor, that is, it is non static and there is no access to it. How can I deal with this trouble?
Answer the question
In order to leave comments, you need to log in
The easy way:
In the "main" class, have a reference to another class in which to implement the button's Title setting method.
The right way:
1. Forget and never remember about static controls.
2. Read about MVVM and other patterns.
3. Implement the application using the pattern you like.
You can use messages. If the button text should change, then in the source class we send a message, and in the class in which the button text should change, we subscribe to this message. More details on how it works here: https://metanit.com/sharp/xamarin/5.4.php
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question