I am currently working with a static method on my page (It is static because it works with other pages). At the end of this method I foreach the results of a list and give the x:name of my label (that i have created in my XAML page) a new text.
To test to see if it worked I write out the labels text in the log and the correct text indeed gets written out, however the text does not get updated on the app.
The code looks something like this:
public static MyPage currentpage = new MyPage();
This is the current page that i am working on. In order to reach the labels x:name I created this code.
And then this is the static method on this page also.
public static async Task loadTheData(string token) //method is static because i send a token from another page
{
...
foreach (var profileinfo in App.registeredUsers) //this is my list
{
currentpage.myXAMLlabel.Text = profileinfo.name; //this is the label where i assign the new text
}
System.Diagnostics.Debug.WriteLine(currentpage.myXAMLlabel.Text); //the correct text gets written out in the log but the text does not get updated "visually" on the app
}
So as I mentioned above, I get the correct text in the log but the text of the label does not get updated "visually" on the app screen.
I call the static method firstly from the specific iOS/Android folders:
App.SuccessfulLoginAction.Invoke();
And on my app-page I have the following method:
public static Action SuccessfulLoginAction
{
get
{
return new Action(async () =>
{
await MyPage.loadTheData(token);
});
}
}
I could move the SuccessfulLoginAction to MyPage instead of having it on the App page. But the method has to still be static i suppose (?) in order for the iOS code to reach the Action.
How can I adjust my code to solve this problem?
public static MyPage currentpage = new MyPage();but it is not working correctly. - Martmanstaticis just ugly and a bad idea but not the core problem here. - Henk Holterman