2012-07-26 55 views
0

我已經爲wp7創建了一個Web瀏覽器。以下是我在我的應用程序中使用的代碼。但是會發生什麼圖像是空白的(白色圖像)請參閱以下圖片。任何人都可以幫助我嗎?謝謝你的幫助。如何在wp7的外殼瓷磚上創建網頁

private void PinToStart_Click(object sender, EventArgs e) 
    { 
     string _url = UrlTextBox.Text; 

     ShellTile TileToFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains("url=" + _url)); 

     using (var store = IsolatedStorageFile.GetUserStoreForApplication()) 
     { 
      var bmp = new WriteableBitmap(173, 173); 
      var tt = new TranslateTransform(); 
      tt.X = 0; 
      tt.Y = 0; 
      bmp.Render(browsers[this.currentIndex], tt); 
      bmp.Invalidate(); 
      var filename = "/Shared/ShellContent/01d.jpg"; 
      using (var st = new IsolatedStorageFileStream(filename, FileMode.OpenOrCreate, FileAccess.Write, store)) 
      { 
       bmp.SaveJpeg(st, 173, 173, 0, 100); 
      } 
     } 

     // Create the Tile if we didn't find that it already exists. 
     if (TileToFind == null) 
     { 
      StandardTileData NewTileData = new StandardTileData 
      { 
       BackgroundImage = new System.Uri("isostore:/Shared/ShellContent/01d.jpg", System.UriKind.Absolute), 
       Title = string.Format(_url.Substring(7)), 
       BackTitle = "Browser", 
       BackContent = (string)_url.Substring(7), 
       BackBackgroundImage = new Uri("", UriKind.Relative) 
      }; 

      // Create the Tile and pin it to Start. This will cause a navigation to Start and a deactivation of our application. 
      ShellTile.Create(new Uri("/Web.xaml?passedUrl=" + _url, UriKind.Relative), NewTileData); 
     } 
     else 
     { 
      MessageBox.Show("A live tile already created for this service. Please check it out!!!"); 
     } 
    } 

enter image description here

回答

1

你需要做的是,呈現HTML內幕一個WriteableBitmap的,所得保存爲173x173文件的內容。

我不確定你是否可以像IE一樣呈現瀏覽器控件。

你的運氣了..閱讀本https://stackoverflow.com/a/6479233/1306871

網頁瀏覽器在WriteableBitmap的不呈現,由於一些錯誤

+0

我編輯了我的帖子,請看看它。它還有其他一些問題,**一張空白圖片**。 – 2012-07-26 17:25:34

+0

這個東西(固定web瀏覽器)不僅在IE中完成。這已經被很多應用開發者完成了。所以,這是可能的,但如何? – 2012-07-27 12:37:29

1
Canvas canvas = new Canvas(); 
canvas .Width = 173; 
canvas.Height = 173; 
WriteableBitmap wpm= new WriteableBitmap(173, 173); 
using (MemoryStream mem = new MemoryStream()){Image image = new Image(); 
image.Source = browsers[this.currentIndex]; 
can.Children.Add(image);     
TranslateTransform translateTransform = new TranslateTransform(); 
translateTransform.X = 0; 
translateTransform.Y = 0; 
wpm.Render(canvas, translate Transform); 
}  
wpm.Invalidate();     
wpm.SaveJpeg(mem, 768, 200, 0, 100); 
var filename = "/Shared/ShellContent/01d.jpg"; 
using (var st = new IsolatedStorageFileStream(filename, FileMode.OpenOrCreate, FileAccess.Write, store)){bmp.SaveJpeg(st, 173, 173, 0, 100);} 

編寫代碼來創建瓷磚 希望有幫助...