Xamarin MVVM passing data to other view

后端 未结 3 996
温柔的废话
温柔的废话 2021-01-27 09:57

I want to pass the data to another view page. So far I can get the data I need to pass. My problem is how do I pass the data in MVVM. I used Application.Current.MainPage.Navigat

3条回答
  •  滥情空心
    2021-01-27 10:25

    If you want to send the int. First declare that in your DatabaseSyncPage Like below

    public partial class DatabaseSyncPage : ContentPage
    {
        public DatabaseSyncPage( int Id)
        {
        }
    }
    

    & when you are pushing your page in your code else block do like this

    if (content.Equals("[]") || string.IsNullOrWhiteSpace(content) || string.IsNullOrEmpty(content))
    {
        MessagingCenter.Send(this, "Http", Username);
    }
    else
    {
        var result = JsonConvert.DeserializeObject>(content);
        var contactId = result[0].ContactID;
        Application.Current.MainPage.Navigation.PushAsync(new DatabaseSyncPage(contactId), true);
    }
    

提交回复
热议问题