Xamarin.forms 我想在同一页面上上传图像 [英] Xamarin.forms i want to upload image on same page

查看:25
本文介绍了Xamarin.forms 我想在同一页面上上传图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 plugins.media 上传我的图像,但问题是它重定向到另一个照片图像页面并将其上传到那里.

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
        };
    }
}

推荐答案

代替做

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

你可以做类似的事情

var img = new Image
        {
            Source =im
        };

然后将新的 img 控件添加到已添加配置文件"控件的同一容器中(可能是某些 Stacklayout 或 Grid 或其他类似的布局控件)

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)

请注意,您正在为构建应用 UI 的最基本概念而苦苦挣扎,这是一个强有力的指标,您应该阅读一些 xamarin.forms 入门教程并真正了解 UI 是如何构建的.

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.

这篇关于Xamarin.forms 我想在同一页面上上传图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆