简体   繁体   English

将图像控件绑定到WP7中的URI

[英]Binding Image Control to URI in WP7

I ham developing an application for WP7 and i am having a strange problem with Image control, it does not show the image it is binded to. 我无法为WP7开发应用程序,并且Image控件遇到一个奇怪的问题,它没有显示它绑定到的图像。

I have tryed it in so many ways but event this way (the most naive one) does not work: 我已经尝试了很多方法,但是这种方法(最幼稚的方法)无法正常工作:

In the xaml I have an Image control named img and this is what I have done in the code behind 在xaml中,我有一个名为img的图像控件,这就是我在后面的代码中所做的事情

    public MainPage()
    {
        InitializeComponent();
        img.Source = new BitmapImage(new Uri   (@"http://img11.imageshack.us/img11/5365/photovnj.jpg", UriKind.Absolute));
    }

</code>

It seems to simple not to work... Please help! 似乎不起作用很简单...请帮助!

This code works fine for me presuming you have img declared as an Image in your xaml. 假设您在xaml中将img声明为Image ,则此代码对我来说效果很好。

If not, I'd suggest you have a connection problem from your app running in the emulator or device to the internet. 如果不是,我建议您在模拟器或设备上运行的应用程序与互联网之间存在连接问题。

This is the code I wrote. 这是我写的代码。

image1.Source = new BitmapImage(new Uri(@"http://img11.imageshack.us/img11/5365/photovnj.jpg", UriKind.Absolute));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM