-2

我想在此处将 DisplayName 导航到下一页 我粘贴了一个代码,DisplayName 无法导航到下一页

        this.DisplayedContacts = new ObservableCollection<string>();

        this.DataContext = this.DisplayedContacts;

        var contacts = new Contacts();

        contacts.SearchCompleted += (s, e) =>
        {
            foreach (var contact in e.Results)
            {

                this.DisplayedContacts.Add(contact.DisplayName + " - " +
                (contact.PhoneNumbers.Any()
                    ? contact.PhoneNumbers.First().PhoneNumber
                    : string.Empty));
            } };

        contacts.SearchAsync(string.Empty, FilterKind.DisplayName, null);
    }

    void MakeCall(bool bWithVideo)
    {

        NavigationService.Navigate(new Uri(NavigationUri.BuildMakeCallUriString("/CallPage.xaml", DisplayName, bWithVideo), UriKind.Relative));
    }

    public ObservableCollection<string> DisplayedContacts { get; set; }

    private void callcon_Click_1(object sender, RoutedEventArgs e)
    {
             MakeCall(e.OriginalSource == callcon);
    }

    public string PhoneNumbers { get; set; }

    public string DisplayName { get; set; }
4

1 回答 1

0

我认为您没有对 MakeCall 方法进行正确的查询字符串。

你可以用这个

void MakeCall(bool bWithVideo)
{

   string QueryString =string.Format("{0},{1}",DisplayName,bWithVideo);
                            NavigationService.Navigate(new Uri("/CallPage.xaml?q=" + QueryString, UriKind.RelativeOrAbsolute));
}

并在下一页处理 NavigationContext

string strCodeTiers = string.Empty;

        if (NavigationContext.QueryString.TryGetValue("q", out strCodeTiers))
        {
            string[] nums = strCodeTiers.Split(',');
            string DisplayName = nums[0];
            string bWithVideo = nums[1];
            bool BWithVideo =Convert.toBool(bWithVideo);

        }
于 2013-07-18T08:01:14.917 回答