Xamarin.forms i want to upload image on same page

烂漫一生 提交于 2019-12-25 07:16:02

问题


i am uploading my image by using plugins.media but the problem is it redirect to another photoimage page and upload it there.

        var profiletap = new TapGestureRecognizer();

        profiletap.Tapped += async (s, e) =>
        {
           var file = await CrossMedia.Current.PickPhotoAsync();
            if (file == null)
                return;
   await DisplayAlert("File Location", file.Path, "OK");

            ImageSource im = ImageSource.FromStream(() =>
            {
                var stream = file.GetStream();
                file.Dispose();
                return stream;

            });




       await Navigation.PushModalAsync(new PhotoPage(im));
        };

        profile.GestureRecognizers.Add(profiletap);

ant here is photopage content

 public class PhotoPage : demopage
{
    public PhotoPage(ImageSource img)
    {
        Content = new Image
        {
            VerticalOptions =LayoutOptions.Start,
            HorizontalOptions = LayoutOptions.Start,
            Source =img
        };
    }
}

回答1:


Instead of doing

await Navigation.PushModalAsync(new PhotoPage(im));

you can do something like

var img = new Image
        {
            Source =im
        };

then add the new img control to the same container as where the "profile" control has already been added (probably some Stacklayout or Grid or some other layout control like that)

Be aware that you are struggling with the most basic concept of building out your app UI, which is a strong indicator you should read some getting started tutorials for xamarin.forms and really understand how the UI is built.



来源:https://stackoverflow.com/questions/37695845/xamarin-forms-i-want-to-upload-image-on-same-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!