private void ShowContactCardWithOptions_Click(object sender, RoutedEventArgs e) { Contact contact = rootPage.CreateContactFromUserInput(EmailAddress, PhoneNumber); if (contact != null) { // Show the contact card next to the button. Rect rect = MainPage.GetElementRect(sender as FrameworkElement); // Ask for the initial tab to be Phone. ContactCardOptions options = new ContactCardOptions() { InitialTabKind = ContactCardTabKind.Phone }; // Show with default placement. ContactManager.ShowContactCard(contact, rect, Placement.Default, options); } }
private async void ShowContactCard_Click(object sender, RoutedEventArgs e) { Contact contact = CreatePlaceholderContact(); // Show the contact card next to the button. Rect rect = MainPage.GetElementRect(sender as FrameworkElement); // The contact card placement can change when it is updated with more data. For improved user experience, specify placement // of the card so that it has space to grow and will not need to be repositioned. In this case, default placement first places // the card above the button because the card is small, but after the card is updated with more data, the operating system moves // the card below the button to fit the card's expanded size. Specifying that the contact card is placed below at the beginning // avoids this repositioning. Placement placement = Placement.Below; // For demonstration purposes, we ask for the Enterprise contact card. ContactCardOptions options = new ContactCardOptions() { HeaderKind = ContactCardHeaderKind.Enterprise }; using (ContactCardDelayedDataLoader dataLoader = ContactManager.ShowDelayLoadedContactCard(contact, rect, placement, options)) { if (dataLoader != null) { // Simulate downloading more data from the network for the contact. this.rootPage.NotifyUser("Simulating download...", NotifyType.StatusMessage); Contact fullContact = await DownloadContactDataAsync(contact); if (fullContact != null) { // Update the contact card with the full set of contact data. dataLoader.SetData(fullContact); this.rootPage.NotifyUser("Contact has been updated with downloaded data.", NotifyType.StatusMessage); } else { this.rootPage.NotifyUser("No further information available.", NotifyType.StatusMessage); } } else { this.rootPage.NotifyUser("ShowDelayLoadedContactCard is not supported by this device.", NotifyType.ErrorMessage); } // The "using" statement will dispose the dataLoader for us. } }
private async void ShowContactCard_Click(object sender, RoutedEventArgs e) { Contact contact = CreatePlaceholderContact(); // Show the contact card next to the button. Rect rect = MainPage.GetElementRect(sender as FrameworkElement); // The contact card placement can change when it is updated with more data. For improved user experience, specify placement // of the card so that it has space to grow and will not need to be repositioned. In this case, default placement first places // the card above the button because the card is small, but after the card is updated with more data, the operating system moves // the card below the button to fit the card's expanded size. Specifying that the contact card is placed below at the beginning // avoids this repositioning. Placement placement = Placement.Below; // For demonstration purposes, we ask for the Enterprise contact card. ContactCardOptions options = new ContactCardOptions() { HeaderKind = ContactCardHeaderKind.Enterprise }; using (ContactCardDelayedDataLoader dataLoader = ContactManager.ShowDelayLoadedContactCard(contact, rect, placement, options)) { // Simulate downloading more data from the network for the contact. this.rootPage.NotifyUser("Simulating download...", NotifyType.StatusMessage); Contact fullContact = await DownloadContactDataAsync(contact); if (fullContact != null) { // Update the contact card with the full set of contact data. dataLoader.SetData(fullContact); this.rootPage.NotifyUser("Contact has been updated with downloaded data.", NotifyType.StatusMessage); } else { this.rootPage.NotifyUser("No further information available.", NotifyType.StatusMessage); } // The "using" statement will dispose the dataLoader for us. } }