将ImageSource位置设置为URL不起作用 [英] Setting ImageSource Location to URL Not Working

查看:175
本文介绍了将ImageSource位置设置为URL不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题,即我动态创建员工列表,然后将图像设置为我们公司门户网站上的照片。  我正在使用Split Metro应用程序。   

I have  an issues where I am dynamically creating a list of employees and then setting an image to their photo that is on our corporate portal.  I am using a Split Metro application.   

以下是我创建员工对象的方法:

Here is how I am creating my employee object:

var emp = new SampleEmployee
(c.UserID
,c.FirstName
,c.LastName
,c.DomainName
,c.UserName
,c.Email
,c.IsActive
,c.FirstName + " " + c.LastName
,c.UserID.ToString()
,c.TitleID.ToString()
,c.Email,
"http://www.myportal.com/Employee%20Photo%20Directory/" + c.FirstName + "%20" + c.LastName + ".jpg",
c.FirstName + " " + c.LastName + " " + c.TravelPreference);


 

当我将URL设置为员工的照片时,我将根据基本URL和名字姓氏创建它。  创建时,一切正常,我可以从调试器获取URL,打开IE,粘贴,图像呈现为预期。

 

When I set the URL to the employee's photo, I am creating it based on the base URL plus First Name Last Name.  When creating this, everything works correctly, I can take the URL from the debugger, open up IE, paste it in, image renders as expected.

在我的员工对象中,这是我如何设置图像属性

In my employee object, this is how I am setting the Image properties

private static Uri _baseCtsUri = new Uri("http://www.myportal.com/HR/Employee%20Photo%20Directory/");

private ImageSource _image = null;
private String _imagePath = null;
public ImageSource Image
{
 get
 {
  if (this._image == null && this._imagePath != null)
  {
   this._image = new BitmapImage(new Uri(Employee._baseCtsUri, this._imagePath));
  }
  return this._image;
 }
 set
 {
   this._imagePath = null;
   this.SetProperty(ref this._image, value);
 }
}

当页面呈现时,我看到的只是默认的灰色框,而不是我门户网站的图像。  我测试了这个以使用我的Assets文件夹中的图像,并使用相同的方法(减去URL路径),图像按预期呈现。  任何人都可以看到我在图像上设置网址的
问题?  如果是XAML绑定问题,那么我希望不会看到来自资产 文件夹的图片。

When the page renders, all I see is the default grey box and not the image from my portal.  I have tested this to use an image in my Assets folder, and using the same method (minus the URL path), the image renders as expected.  Can anyone see an issue with how I am setting the URL on the image?  If it was a XAML binding issue, then I would expected to not see the images from the Assets folder appear.

非常感谢任何帮助或指导。

Any assistance or guidance is greatly appreciated.

推荐答案

嗨克雷格,

尝试删除来自网址的%20 ,并使用实际的
SPACE 替换它。有没有用过? 

Try removing the %20 from the URL and substitute it with the actual SPACE . Has it ever worked? 

-Sagar


这篇关于将ImageSource位置设置为URL不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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