开发者

Windows phone 7, code to indicate how many clicks of an image?

So I had a thought -- Say you have pictures streaming to your app from a webpage. Is there any way to put code in the app to find out how many times a person has tapped the image, or how many times they have pres开发者_高级运维sed a button belonging to the image?

Think of the "Like" button for facebook, where people can have +1, and see the total count of how many people also "like" it.

If so, how would one go about coding this?


You question is very vague...

If you want the count of how many time the image was loaded you can count that server side every time the picture is downloaded. If you want to give them a "like" button then you can add that to your WP7 app and call a page server side or a WCF service with some ID value for the picture to track the "likes".

For example: HTTP Version

You can download the pictures from you webserver using a link such as "http://www.mysite.com/pictures.aspx?ID=Funnyfile.jpg&DeviceID=29393848293".

ID would be the unique ID for your application to know which picture to load DeviceID would be the Device ID for the WP7 device loading the picture in your app (MSDN doesn't recommend you use the Device ID to identify unique users so you might need to adjust this value).

You could then set the source of an Image Control to that URL to load the image.

Uri uri = new Uri("http://www.mysite.com/pictures.aspx?ID=Funnyfile.jpg&DeviceID=29393848293", UriKind.Absolute);
   ImageSource imgSource = new BitmapImage(uri);
   ProfileImage.Source = imgSource;

A WCF Service can use a similar manner and would allow you to pull a collection of images back from the server if you need to. The basics of building the service wouldn't be overly complicated, but I am omitting and example to save time.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜