我使用plugins.media上传我的图片,但问题是它重定向到另一个photoimage页面并将其上传到那里。
var _dbContext = new MyDbContext();
var company = _dbContext.Companies.Include("").SingleOrDefault(c => c.Id == companyId);
var products = _dbContext.Companies.Include("").SingleOrDefault(c => c.Id == companyId)
?.CompanyProducts
.Where(cp => cp.IsBuyable && cp.Product.IsPublished)
.OrderByDescending(c => c.Product.PublishDate)
.ThenBy(c => c.Product.Name)
.ToList();
if(company != null)
{
company.CompanyProducts = products;
}
return company;
这里的蚂蚁是照片内容
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);
答案 0 :(得分:0)
而不是做
await Navigation.PushModalAsync(new PhotoPage(im));
你可以做点什么
var img = new Image
{
Source =im
};
然后将新的img控件添加到与已添加“profile”控件的位置相同的容器中(可能是某些Stacklayout或Grid或其他类似的布局控件)
请注意,您正在努力构建应用UI的最基本概念,这是一个强有力的指标,您应该阅读一些xamarin.forms的入门教程,并真正了解如何构建UI。