在WP7的picture hub中,選中一張圖片,查看圖片時,點擊“…”菜單,點share…時,會出現一個菜單(這個菜單中就是可以對選中的圖片進行分享或者處理的應用列表)
下面介紹如何?這個一鍵分享功能:1.建立share picker xml檔案2.擷取和處理圖片在你的應用程式中建立一個叫“E0F0E49A-3EB1-4970-B780-45DA41EC7C28.xml”的XML檔案注意:請把檔案的 Copy to Output Directory的屬性設定成Copy always.這樣你的應用就會出現在share...中了,但是如何處理選中的圖片了,實際上,從share...中啟動你的應用時,圖片會通過導航參數“FileId”傳遞給你的應用程式.得到該圖片樣本如下:
protected override void OnNavigatedTo(NavigationEventArgs e){ // Get a dictionary of query string keys and values. IDictionary<string, string> queryStrings = this.NavigationContext.QueryString; // Ensure that there is at least one key in the query string, and check // if the "FileId" key is present. if (queryStrings.ContainsKey("FileId")) { // Retrieve the picture from the local Zune Media database using the FileID // passed to the application. MediaLibrary library = new MediaLibrary(); Picture picture = library.GetPictureFromToken(queryStrings["FileId"]); // Create a WriteableBitmap object and add it to the Image control Source property. BitmapImage bitmap = new BitmapImage(); bitmap.SetSource(picture.GetImage()); WriteableBitmap picLibraryImage = new WriteableBitmap(bitmap); retrievePic.Source = picLibraryImage; }}