Hello,
i want it operate a function to update the text in lable or entry to dispalay the text the problem that i recive text
You can use Xamarin.Forms MessagingCenter to achieve it. For example, you receive the message from the background service or other native platform(such as Android BroadCastReceiver). You can send Message by
MessagingCenter.Send<App, string>(App.Current as App, "OneMessage", "this is recieved wifi information");
If you have a Label in the MainPage.xaml called myLabel
, when you receive the Message, you can update it like following background code.
public MainPage()
{
InitializeComponent();
MessagingCenter.Subscribe<App, string>(App.Current, "OneMessage", (snd, arg) =>
{
Device.BeginInvokeOnMainThread(() => {
//Update the Label‘s text, if received the Message
myLabel.Text = arg;
});
});
}
Best Regards,
Leon Lu
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.