c# - creating standard tiles with background image from internet -


i want create standarttile background image direct website,

and fine in wp8, same code not work in wp7

here code below:

void settile(string title, string iconpath1x1, string iconpath2x2,              string iconpath4x2, string iconpath2x2back, string iconpath4x2back,              string widecontent, string targeturi) {     standardtiledata standarddata = new standardtiledata()     {             //iconpath2x2 = "http://i.imgur.com/something.png"             title = title + "_",             backgroundimage = new uri(iconpath2x2, urikind.relativeorabsolute),              backcontent = "",             backtitle = title + "_",              backbackgroundimage = new uri(iconpath1x1, urikind.absolute)     };      shelltile tiletopin = shelltile.activetiles.firstordefault(                           x => x.navigationuri.tostring().contains(targeturi));      if (tiletopin == null)     {         shelltile.create(             new uri(targeturi, urikind.relativeorabsolute), standarddata);     } } 

i have tried link, didn't work

http://blog.safaribooksonline.com/2012/03/20/windows-phone-7-bringing-your-application-tile-to-life/

do miss or doesn't work in wp7?

unfortunately you'll need download image , save locally. can refer image isolated storage

string filename = @"shared\shellcontent\backgroundtileimage.jpg"; if(trysaveimage(filename, "http://foo.com/bar.png")) {     uri uri = new uri("isostore:/" + filename, urikind.absolute);     // create tile if didn't find exists.     var tiledata = new standardtiledata     {         title = "my tile",         backgroundimage = uri,     }; }  ... private bool trysaveimage(string filename, string url) {     using (var store = system.io.isolatedstorage.isolatedstoragefile.getuserstoreforapplication())     {         try         {             var backimage = new image();             backimage.height = backimage.width = 173;             backimage.stretch = stretch.none;             backimage.source = new bitmapimage(new uri(url));             backimage.measure(new size(173, 173));             backimage.arrange(new rect(0, 0, 173, 173));             var image = new writeablebitmap(backimage, null);              string directory = path.getdirectoryname(filename);             if (!store.directoryexists(directory))             {                 store.createdirectory(directory);             }             using (var stream = store.openfile(filename, filemode.openorcreate))             {                 image.savejpeg(stream, 173, 173, 0, 100);             }         }         catch         {             return false;         }     }     return true; } 

Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -