Đang chuẩn bị liên kết để tải về tài liệu:
programming windows phone 7 phần 6
Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Điều này thực sự hoạt động trong ví dụ này, nhưng nó rất, rất sai. Vấn đề là tài sản Nội dung của Button là kiểu của đối tượng. Chúng ta có thể thiết lập nó để hình ảnh bất cứ điều gì, Panel, Shape một, RadialGradientBrush một, và sau đó TextBlock sẽ có một vấn đề nhỏ. | appbarSaveButton.IsEnabled true The monochromized WriteableBitmap is set to the Source property of the Image element and the save button is enabled. Pressing the save button navigates to the SaveFileDialog.xaml page in the Petzold.Phone.Silverlight library. As you ve just seen the SaveFileDialog class handles its OnNavigatedFrom override by calling the SaveFileDialogCompleted method in the class that it s navigating to Silverlight Project Monochromize File MainPage.xaml.cs excerpt void OnAppbarSaveClick object sender EventArgs args this.NavigationService.Navigate new Uri Petzold.Phone.Silverlight component SaveFileDialog.xaml UriKind.Relative public void SaveFileDialogCompleted bool okPressed string filename if okPressed MemoryStream memoryStream new MemoryStream 495 writeableBitmap.SaveJpeg memoryStream wri teableBitmap.PixelWidth writeableBitmap.PixelHeight 0 75 memoryStream.Position 0 MediaLibrary mediaLib new MediaLibrary mediaLib.SavePicture filename memoryStream The SaveFileDialogCompleted method uses the filename entered by the user to write the bitmap to the pictures library. This happens in two steps First the SaveJpeg method writes the WriteableBitmap to a Memorystream in JPEG format. The Position on the Memorystream is then reset and the stream is saved to the pictures library. The Monochromize program also handles tombstoning. The OnNavigatedFrom method uses the SaveJpeg extension method to write to a MemoryStream and then saves the byte array. This method is also responsible for calling SetTitle on the SaveFileDialog if navigating to that page Silverlight Project Monochromize File MainPage.xaml.cs excerpt protected override void OnNavigatedFrom NavigationEventArgs args if writeableBitmap null MemoryStream stream new MemoryStream writeableBitmap.SaveJpeg stream writeableBitmap.PixelWi dth writeableBitmap.PixelHeight 0 75 appService.State jpegBits stream.GetBuffer if args.Content is SaveFileDialog SaveFileDialog page args.Content as SaveFileDialog .