windows-runtime

Uri Formatting on Image Source

喜欢而已 提交于 2019-12-10 20:46:04
问题 What is wrong with the following uri? bmi.UriSource = (new Uri(@"/Assets/Image.png", UriKind.Relative)); Where bmi is a BitmapImage . I have the build action for the image set to Embedded Resource. 回答1: Found it; bmi.UriSource = (new Uri("ms-appx:/Assets/Logo.png")); And build action set to Content. There's no Relative URI in RT. 回答2: WPF needs to use the Resource build action (or Content build action) to use Uris. For binary data (like an image), use Binary. If you're using a single project

Convert IRandomAccessStreamWithContentType to Byte[]

假如想象 提交于 2019-12-10 20:06:33
问题 In my application, I allow users to add people from contact using the ContactPicker. I try to convert IRandomAccessStreamWithContentType to Byte[] IRandomAccessStreamWithContentType stream = await contactInformation.GetThumbnailAsync(); if (stream != null && stream.Size > 0) { Byte[] bytes = new Byte[stream.Size]; await stream.ReadAsync(bytes.AsBuffer(), (uint)stream.Size, Windows.Storage.Streams.InputStreamOptions.None); My Byte[] is not empty (approximately 10000 bytes) But when I use my

Winrt StreamWriter & StorageFile does not completely Overwrite File

不想你离开。 提交于 2019-12-10 19:35:10
问题 Quick search here yielded nothing. So, I have started using some rather roundabout ways to use StreamWriter in my WinRT Application. Reading works well, writing works differently. What' I'm seeing is that when I select my file to write, if I choose a new file then no problem. The file is created as I expect. If I choose to overwrite a file, then the file is overwritten to a point, but the point where the stream stops writing, if the original file was large, then the old contents exist past

Is there a way to store instances of own classes in the ApplicationSettings of a Windows Store app?

∥☆過路亽.° 提交于 2019-12-10 19:17:35
问题 In a Windows Store app I can only store WinRT types in the ApplicationSettings, according to the documentation. For roamed settings that should be held together I can use ApplicationDataCompositeValue. Trying to store an instance of an own class or struct results in an Exception with the message " WinRT information: Error trying to serialize the value to be written to the application data store. Additional Information: Data of this type is not supported". The term "trying to serialize"

How to make Window.Current visible after it was closed?

吃可爱长大的小学妹 提交于 2019-12-10 19:01:51
问题 I have an application that opens new windows. If the original window is closed and then the user starts the app (e.g. from the start menu) - TryShowAsStandaloneAsync fails in opening a new window (Why?). So I want to "revive" the original one. But though I use Window.Current.Activate(); and frame.Navigate(...); - Window.Current.Visible is always false (and the window is not shown again). So how can I "revive" a closed window? (Or use TryShowAsStandaloneAsync from a closed window.) 回答1: I

“The buffer allocated is insufficient” exception while calling BitmapEncoder.SetPixelData

隐身守侯 提交于 2019-12-10 19:00:15
问题 I want to create a white image run time in my Windows 8 app. I thought I will create a byte array and then will write onto file. But I am getting exception The buffer allocated is insufficient. (Exception from HRESULT: 0x88982F8C) . What's wrong with my code? double dpi = 96; int width = 128; int height = 128; byte[] pixelData = new byte[width * height]; for (int y = 0; y < height; ++y) { int yIndex = y * width; for (int x = 0; x < width; ++x) { pixelData[x + yIndex] = (byte)(255); } } var

Porting C# reflection code to Metro-Ui

醉酒当歌 提交于 2019-12-10 18:58:25
问题 I'm trying to port an existing C# class (a generic factory) that uses reflection, but I can't get this piece of code to compile: Type[] types = Assembly.GetAssembly(typeof(TProduct)).GetTypes(); foreach (Type type in types) { if (!typeof(TProduct).IsAssignableFrom(type) || type == typeof(TProduct)) ... I tried looking at the Reflection in the .NET Framework for Windows Metro Style Apps and Assembly Class, where I found an example that didn't compile because of the "using System.Security

Win 8 RT routing parameters

旧街凉风 提交于 2019-12-10 18:49:11
问题 I have to route through different pages and pass routing parameters between them. I have made that happen and I am passing the parameters but I do not have access to the object property. void itemClick(object sender, ItemClickEventArgs e) { this.Frame.Navigate(typeof(Views.SongPicker) , e.ClickedItem ); } and on the other page I recive the parameter object as a navigation parameter. protected override void LoadState(Object navigationParameter, Dictionary<String, Object> pageState) { } I have

how to disable caching HTTP GET in metro app, I am using IXMLHTTPRequest2

六眼飞鱼酱① 提交于 2019-12-10 18:10:18
问题 I am doing an http GET to fetch data, I am using IXMLHTTPRequest2. If I GET url "http://foo.com" (curl "http://foo.com"), the second time I get this url again, the content on server is actually changed, but what I am getting is the cached result. Caching seems only honor URL, so if different header with same URL, still same cached result. I have tried "Cache-Control: no-cache", "Cache Control: no-store", and "Pragma: no-cache". None of them are honored by the API. Is there a way to turn cache

Programmatically dismiss a MessageDialog

橙三吉。 提交于 2019-12-10 18:08:20
问题 On Windows Phone 8.1, how to programmatically dismiss a MessageDialog after the ShowAsync call? I’ve tried calling IAsyncInfo.Close(), it just throws an InvalidOperationException "An illegal state change was requested". I’ve tried calling IAsyncInfo.Cancel(). The dialog stays visible, the only result - after I tap the “Close” button, TaskCancelledException is marshaled to the awaiting routine. Update: exact behavior depends on the sequence of the calls. If IAsyncOperation.Cancel() is invoked