Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

passing an object in the constructor to a clicked event

$
0
0

I'm pretty new to Xamarin and recently start trying to make an App using the Xamarin.Forms

XAML:

<Button Text="Quick Links" BackgroundColor="#99CCFF" Grid.Column = "2" Grid.ColumnSpan="2" TextColor="White" Clicked="OnQuickLinksButtonClicked" Command="{Binding Click}"/>

**Code Behind:
**
public partial class ProfileView : ContentPage
{
Patient globalPatient;
public ProfileView (Patient patient)
{
InitializeComponent ();
BindingContext = new ProfileViewModel (patient);
globalPatient = new Patient();
globalPatient = patient;
}

       async void OnQuickLinksButtonClicked(object sender, EventArgs args)
       {
           await Navigation.PushAsync (new BarCodeView (globalPatient.Name)); 
        }
    }

My question is that how can I pass the patient object to the OnQuickLinksButtonClicked? I test the code above and the globalPatient.Name is empty.

Thanks!


Viewing all articles
Browse latest Browse all 77050

Trending Articles