private async void BtnChangeImg_Click(object sender, RoutedEventArgs e)
        {
            //create ContentDialog called PicturePicker
            PicturePicker picturePicker = new PicturePicker();
            BitmapImage   item          = new BitmapImage();

            //show the ContentDialog
            var optionPicked = await picturePicker.ShowAsync();

            switch (optionPicked)
            {
            //if he user clicks the Primary (OK) button
            case ContentDialogResult.Primary:

                // display image picked
                if (App.IsPictureSelected == true)
                {
                    item.UriSource = new Uri("ms-appx://" + App.picturePicked);
                    imgItem.Source = item;
                    currentImage   = App.picturePicked;
                }

                //close ContentDialog
                break;

            //if Secondary (Cancel) button is clicked
            //close ContentDialog
            case ContentDialogResult.Secondary:
                break;
            }
        }
Ejemplo n.º 2
0
        private async void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
        {
            MessageDialog dialog;

            //if a gridItem is not selected
            if (gridPictures.SelectedIndex == -1)
            {
                //set IsPictureSelected to false
                App.IsPictureSelected = false;
                //display error message
                dialog = new MessageDialog("Please select an image first");
                await dialog.ShowAsync();

                //redisplay Picture Picker Content Dialog
                PicturePicker picker = new PicturePicker();
                await picker.ShowAsync();
            }
            else
            {
                //set IsPictureSelected to true
                App.IsPictureSelected = true;
            }
        }