Tag: windows phone 7

将BitmapImage转换为Byte数组

我想在Windows Phone 7应用程序中将BitmapImage转换为ByteArray。 所以我尝试了这个,但它抛出了运行时exception“无效的指针exception”。 任何人都可以解释为什么我要做的事情会引发exception。 您能为此提供替代解决方案吗? public static byte[] ConvertToBytes(this BitmapImage bitmapImage) { byte[] data; // Get an Image Stream using (MemoryStream ms = new MemoryStream()) { WriteableBitmap btmMap = new WriteableBitmap(bitmapImage); // write an image into the stream Extensions.SaveJpeg(btmMap, ms, bitmapImage.PixelWidth, bitmapImage.PixelHeight, 0, 100); // reset the stream pointer to the beginning ms.Seek(0, 0); […]

如何以编程方式设置WP7中选定的Panorama项目

我在WP7应用程序中使用全景控件。 其中一个PanoramaItem将您带到另一个页面,然后允许您通过EmailComposeTask发送电子邮件。 如果您未选择发送电子邮件并按后退按钮,则Panorama将返回上次选择的项目。 但是,如果您选择发送电子邮件(因此离开应用程序),则不会返回先前选择的PanoramaItem。 相反,它返回到Panorama中的第一个项目。 我试着跟踪所选索引并设置它,但是我收到一条错误,说SelectedIndex不可设置。 这已在MSDN文档中得到确认http://msdn.microsoft.com/en-us/library/microsoft.phone.controls.panorama.selectedindex%28VS.92%29.aspx 有没有办法在全景图上手动设置所选索引/项目? 如果没有,有没有办法让它记住所选的内容,即使用户离开应用程序撰写电子邮件?

如何在Windows Phone中在后台运行应用程序?

我想在Windows Phone 8中开发一个后台应用程序。就像有一个闪存屏幕,在闪存屏幕启动后,立即将它移到后面。 但是应用程序中存在的计时器应该在后台处于活动状态并继续执行分配的任务。 因此,在前台用户可以继续使用该设备,在后台,应用程序将运行计时器并继续执行任务。 我尝试过使用Periodic任务,但是它们会在30分钟甚至更长时间内触发一次。 但我希望这个应用程序在20秒内触发一次。 请帮助我一些想法。

Windows Phone 8上存在哪些URI协议?

我已经在网上搜索了一个完整的URI协议列表(XXX://),以便在Windows Phone 8中打开不同的应用程序。我找到了一些列表但只有极少量的协议。 我正在使用这个wiki-post,希望能够制作完整的协议列表,并至少涵盖Windows Phone 8中的所有股票应用程序。 例如,有许多部分列表: http : //developer.nokia.com/Community/Wiki/URI_Association_Schemes_List http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj662937(v=vs.105 )的.aspx 但是我认为如果我们能够编译所有URL方案的大清单会很棒。 即使是未记录的URL方案也会很有趣。

在Webbrowser控件中使用本地图像

我在我的Wp7应用程序中使用Web浏览器控件,但我似乎无法在Web浏览器中放置App目录中的图像。 我将一些图像放在与.cs和.xaml文件相同的目录中的文件夹中。 现在我尝试将它们放在webbrowser控件中,但我似乎无法让它工作。 上面两个显然不起作用,我的猜测应该是这样的: “SilverlightApplication”和“组件”应该被其他东西取代,但我不知道:(

将图像转换为base64

我有以下代码将图像转换为base64: private void btnSave_Click(object sender, RoutedEventArgs e) { StreamResourceInfo sri = null; Uri uri = new Uri(“Checked.png”, UriKind.Relative); sri = Application.GetResourceStream(uri); BitmapImage bitmap = new BitmapImage(); bitmap.SetSource(sri.Stream); WriteableBitmap wb = new WriteableBitmap(bitmap); MemoryStream ms = new MemoryStream(); wb.SaveJpeg(ms, bitmap.PixelWidth, bitmap.PixelHeight, 0, 100); byte[] imageBytes = ms.ToArray(); base64 = System.Convert.ToBase64String(imageBytes); } 以下代码获取位图图像formsbase 64: public static BitmapImage […]

如何使用DataTemplate访问列表框中的特定项目?

我有一个ListBox,包括一个带有2个StackPanels的ItemTemplate。 我想要访问的第二个StackPanel中有一个TextBox。 (将其可见性更改为true并接受用户输入)触发器应为SelectionChangedEvent。 因此,如果用户单击ListBoxItem,TextBlock将变为不可见,TextBox将变为可见。 XAML代码: 我想有几种方法可以解决这个问题,但我没有尝试过。 我目前的做法是这样的 private void ContactListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { ListBoxItem listBoxItem = ContactListBox.SelectedItem as ListBoxItem; DataTemplate listBoxTemplate = listBoxItem.ContentTemplate; // How to access the DataTemplate content? StackPanel outerStackPanel = listBoxTemplate.XXX as StackPanel; StackPanel innerStackPanel = outerStackPanel.Children[1] as StackPanel; TextBox nameBox = innerStackPanel.Children[0] as TextBox; TextBlock nameBlock = innerStackPanel.Children[1] as TextBlock; […]