简体   繁体   English

绑定之前如何在WP7中获取图像

[英]Before Binding how to get the image in WP7

I have worked for Image binding for listbox. 我曾为列表框绑定图像。 For that I have binded the Image Url to Image Source. 为此,我将“图像网址”绑定到“图像源”。 My proplem is someURL not valid does not contain image. 我的建议是someURL无效,不包含图片。 Normally I have loaded defalut image for no url contains items. 通常我已经加载了defalut图片,因为其中没有url包含项目。

That not valid url, binded the image as empty pixel. 无效的网址将图片绑定为空白像素。 In this i want to show default image. 在此,我想显示默认图像。 If no pixel in image means, binding not needed. 如果图像中没有像素,则表示不需要绑定。

string Url="Some URl.jpg"; 字符串Url =“ Some URl.jpg”;

Binded this "URL" to the Image. 将此“ URL”绑定到图像。

Pls Help me 请帮助我

为此,请尝试在您的图片内容中提供与您图片内容尺寸相等的背景图片。默认情况下,URL中没有图片时会显示背景图片。

Use Stackpanel at background, so when image is loading , it will show by default color of stackpanel, and when image is loaded it will show Image, thereby hiding the background color 在背景上使用Stackpanel,因此在加载图像时,它将默认显示stackpanel的颜色,而在加载图像时,它将显示Image,从而隐藏背景色

StackPanel background = new StackPanel();
background.Background = new SolidColorBrush(Colors.LightGray);

Image img1 = new Image();
img1.Height = 250;
img1.Stretch = Stretch.UniformToFill;

LowProfileImageLoader.SetUriSource(img1, new Uri(n.Image, UriKind.RelativeOrAbsolute));
background.Children.Add(img1);

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

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