Hello,
You can do this by changing type of color property to Microsoft.Maui.Graphics.Color
in the MainViewModel.cs
like following code.
public partial class MainViewModel : ObservableObject
{
[ObservableProperty]
private string vcard;
[ObservableProperty]
private Color color;
}
Then open your private void OnCounterClicked(object sender, EventArgs e)
method of MainPage
's background code and change your set color's way like following code.
private void OnCounterClicked(object sender, EventArgs e)
{
// ((MainViewModel)(this.BindingContext)).Vcard = "yahoo";
vm.Vcard = "BEGIN:VCARD\nVERSION:3.0\nFN:John Doe\nTEL;TYPE=WORK,VOICE:(555) 555-5555\nEMAIL;TYPE=PREF,INTERNET:johndoe@example.com\nEND:VCARD";
vm.Color = Color.FromArgb("#FFFF00");
this.ShowPopup(new ContactQR(vm)); }
In the end, please add BindingContext = vm;
in the ContactQR
's background code.
public ContactQR(MainViewModel vm)
{
InitializeComponent();
BindingContext = vm;
}
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.