After photo gallery browsing it goes back to the first page

VuyiswaMasekoVuyiswaMaseko USMember ✭✭

Good Day

in my Xamarin page i have a button that browse the gallery to allow a user to bind it to an image editor , after selecting the image , the page refreshes to the first page that led to this current page. i would like to make it keep it in the current page after image selection . below is the code on my button

async private void Btnupload_Clicked(object sender, EventArgs e)
        {
            GenericMethods.IS_IMAGE_SELECTON = true;
                if (!CrossMedia.Current.IsPickPhotoSupported)
                {
                    await DisplayAlert("Photos Not Supported", ":( Permission not granted to photos.", "OK");
                    return;
                }
                var file = await CrossMedia.Current.PickPhotoAsync(new Plugin.Media.Abstractions.PickMediaOptions
                {
                    PhotoSize = Plugin.Media.Abstractions.PhotoSize.Medium
                });

                if (file == null)
                    return;

                filePath = file.Path;
                paths.Enqueue(filePath);

                //Linux path 
                readytosave = GenericMethods.StreamToByteArray(file.GetStream());

                Uri uri = new Uri(file.Path);
                filename = string.Empty;
                if (uri.IsFile)
                {
                    filename = System.IO.Path.GetFileName(uri.LocalPath);
                }
                var extension = filename.Split('.')[1].ToLower();

                file_extension = extension;

                 imageEditor.Source = ImageSource.FromStream(() =>
                {
                    var stream = file.GetStream();
                    return stream;
                });
            imagepopup.IsOpen = true;
        }

thanks

Best Answer

Answers

  • ColeXColeX Member, Xamarin Team Xamurai

    Could you post complete code or a basic sample ?

  • VuyiswaMasekoVuyiswaMaseko USMember ✭✭

    HI Colex i have attached the example project

  • ColeXColeX Member, Xamarin Team Xamurai

    Everything works fine on my side .

  • VuyiswaMasekoVuyiswaMaseko USMember ✭✭

    This is strange now . can you share with me the version of your Android ? i am using Xiomi latest stable release

  • ColeXColeX Member, Xamarin Team Xamurai

    I test on simulator , Android Version : 9.0(Pie)

  • VuyiswaMasekoVuyiswaMaseko USMember ✭✭

    Thanks , i tried it on another phone it worked except mine.

Sign In or Register to comment.