我想将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; }
答案 0 :(得分: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);
}