GGleGrand
GGleGrand

Reputation: 1650

Bind/set short text data from Android MainActivity.cs to a shared Xamarin Forms Label?

Is there a way to define a Label in Xamarin Forms (XAML or code-behind) AppXYZ that can be updated from the Xamarin Android AppXYZ.Android: MainActivity.cs and AppXYZ.iOS:Main.cs? i.e. upon an event in Android (e.g. BlueTooth) set a short text in a common Forms elements? After viewing many example, no clarity yet. MessageCenter perhaps?

In Android Project: MainActivity.cs (for example): FormsAppXYZ.LabelXYZ.Text = "Updated string";

If not possible, then proper way to do this with Xamarin Android Native ? appreciated since I'll have to mix in the label into a shared Xamarin Forms Tabbed GUI.

Upvotes: 0

Views: 177

Answers (1)

TeamTam
TeamTam

Reputation: 1608

Depending on how much Bluetooth work you need to do, my first suggestion would be to use MessagingCenter as you have already alluded to.

The other obvious approach would be to use a third party plugin, as I don't believe Xamarin have released one. I am currently aware of these two:

Upvotes: 0

Related Questions