private void addPhoto_Click(object sender, RoutedEventArgs e) { // Create a new PhotoInfo object. PhotoInfo newPhotoEntity = new PhotoInfo(); // Ceate an new PhotoDetailsWindow instance with the current // context and the new photo entity. PhotoDetailsWindow addPhotoWindow = new PhotoDetailsWindow(newPhotoEntity, context); addPhotoWindow.Title = "Select a new photo to upload..."; // We need to have the new entity tracked to be able to // call DataServiceContext.SetSaveStream. trackedPhotos.Add(newPhotoEntity); // If we successfully created the new image, then display it. if (addPhotoWindow.ShowDialog() == true) { // Set the index to the new photo. photoComboBox.SelectedItem = newPhotoEntity; } else { // Remove the new entity since the add operation failed. trackedPhotos.Remove(newPhotoEntity); } }
private void photoDetails_Click(object sender, RoutedEventArgs e) { // Get the selected photo. currentPhoto = photoComboBox.SelectedItem as PhotoInfo; // Create an instance of the photo details window. PhotoDetailsWindow photoDetailsWindow = new PhotoDetailsWindow(currentPhoto, context); photoDetailsWindow.Title = string.Format("Details {0}:", currentPhoto.FileName); // Display the dialog. if (photoDetailsWindow.ShowDialog() == true) { // Request the image file again in case it was changed. // We might have also used a client-side copy of the image to avoid // this GET request to the data service. getCurrentPhoto(); } }