/// <summary>
 /// Activates ContactPickerPage.
 /// </summary>
 /// <param name="args">ContactPicker activated args</param>
 public void Activate(ContactPickerActivatedEventArgs args)
 {
     this.contactPickerUI   = args.ContactPickerUI;
     Window.Current.Content = this;
     this.OnNavigatedTo(null);
     Window.Current.Activate();
 }
Esempio n. 2
0
 /// <summary>
 /// Invoked when user removes one of the items from the Picker basket
 /// </summary>
 /// <param name="sender">The FileOpenPickerUI instance used to contain the available files.</param>
 /// <param name="e">Event data that describes the file removed.</param>
 private async void HandleContactPickerUIContactRemoved(ContactPickerUI sender, ContactRemovedEventArgs e)
 {
     await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
     {
         // Synchronize the select items in the UI lists to remove hte item that was removed from the picker's 'basket'
         var removedSelectedGridItem = ContactGridView.SelectedItems.Cast <Contact>().FirstOrDefault(x => x.Id == e.Id);
         if (removedSelectedGridItem != null)
         {
             ContactGridView.SelectedItems.Remove(removedSelectedGridItem);
         }
     });
 }
 async void contactPickerUI_ContactRemoved(ContactPickerUI sender, ContactRemovedEventArgs args)
 {
     // The event handler may be invoked on a background thread, so use the Dispatcher to run the UI-related code on the UI thread.
     string removedId = args.Id;
     await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
     {
         foreach (SampleContact contact in ContactList.SelectedItems)
         {
             if (contact.Id == removedId)
             {
                 ContactList.SelectedItems.Remove(contact);
                 OutputText.Text += "\n" + contact.Name + " was removed from the basket";
                 break;
             }
         }
     });
 }
Esempio n. 4
0
        /// <summary>
        /// Invoked when another application wants to open files from this application.
        /// </summary>
        /// <param name="contactPickerUI">The contact picker user interface element.</param>
        public void Initialize(ContactPickerUI contactPickerUI)
        {
            if (contactPickerUI == null)
            {
                throw new ArgumentNullException("contactPickerUI");
            }

            // Tie into the containing File Picker object
            _contactPickerUI = contactPickerUI;
            _contactPickerUI.ContactRemoved += HandleContactPickerUIContactRemoved;

            // Initialize the ViewModel
            DefaultViewModel["CanGoUp"]         = false;
            DefaultViewModel["ContactGroups"]   = null;
            DefaultViewModel["SelectedContact"] = null;

            // Fetch the data and set it to the View Model
            var sampleDataGroups = AppSampleData.Current.SampleData.Groups
                                   .OrderBy(x => x.Key)
                                   .ToList();

            DefaultViewModel["ContactGroups"] = sampleDataGroups;
        }