windows-store-apps

Adding headers when using httpClient.GetAsync

為{幸葍}努か 提交于 2019-12-17 06:31:14
问题 I'm implementing an API made by other colleagues with Apiary.io, in a Windows Store app project. They show this example of a method I have to implement: var baseAddress = new Uri("https://private-a8014-xxxxxx.apiary-mock.com/"); using (var httpClient = new HttpClient{ BaseAddress = baseAddress }) { using (var response = await httpClient.GetAsync("user/list{?organizationId}")) { string responseData = await response.Content.ReadAsStringAsync(); } } In this and some other methods, I need to have

why does async call LiveConnectClient.GetAsync block executing thread?

半城伤御伤魂 提交于 2019-12-14 03:59:01
问题 I have Windows Store MonoGame (based on XAML MonoGame template in Visual Studio 2012) app. When I connect to LiveConnect, system does all things in background, but when I call LiveConnectClient.GetAsync to get user info it sometimes (and usually) blocks the caller thread, even though it is called using await. Is there any way to make GetAsync call really async? Maybe I should create a new thread to call it? Here's the caller code. It is called inside MonoGame draw thread (can't access main UI

How to detect if a user has closed a winrt application

ε祈祈猫儿з 提交于 2019-12-14 03:42:38
问题 What is a reliable (and immediately) way to detect if a user has closed the app with ALT-F4 or the close-gesture? 回答1: According to the Application Lifecycle documentation there is no way to detect this event (See the section under "App close"). This type of state can be managed best using the ApplicationData class. 回答2: Not really an exact answer to my specific question, but a way which solved my concrete problem for which I posted my question. Maybe it helps someone else: Register to Window

Combobox doesn’t set default value if value is an enum

大城市里の小女人 提交于 2019-12-14 03:21:31
问题 I have an combobox where I provide the options and the value to set from my data context. The xaml looks like this: <ComboBox HorizontalAlignment="Left" Width="120" ItemsSource="{Binding Options}" DisplayMemberPath="Text" SelectedValuePath="OptionValue" SelectedValue="{Binding Value, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" If Value and OptionValue is an int in my datacontext everything works fine. Example: public class MyDataContext : INotifyPropertyChanged { public event

Why does the People app show no contacts / doesn't allow me to pick contacts?

耗尽温柔 提交于 2019-12-14 03:13:47
问题 I'm trying to allow the user to select a contact from the People app this way: private async Task<System.Collections.Generic.KeyValuePair<string, string>> SelectAContactForASlot() { KeyValuePair<string, string> kvp; // = new KeyValuePair<string, string>(); var contactPicker = new Windows.ApplicationModel.Contacts.ContactPicker(); contactPicker.CommitButtonText = "Select"; var contact = await contactPicker.PickSingleContactAsync(); if (contact != null) { kvp = new KeyValuePair<string, string>

Windows Store app 8.1 Xaml pausing/resuming download using http classes

℡╲_俬逩灬. 提交于 2019-12-14 03:03:37
问题 I'm trying to use http classes to pause/resume a download and pausing is easy by using the cancellation token , however how can i resume a download? I have used the background downloader class and it had a lot of issues in resuming and had many other issues to handle downloads. Here is my code: using Windows.Web.Http; using Windows.Web.Http.Filters; private async void Foo(StorageFolder folder, string fileName) { Uri uri = new Uri("http://localhost"); var filter = new HttpBaseProtocolFilter();

How to convert a VirtualKey to a char for non-US keyboard layouts in WinRT?

﹥>﹥吖頭↗ 提交于 2019-12-14 01:07:00
问题 In standard .NET there existed the ToAscii/ToUnicode and MapVirtualKey functions to take care of this functionality, though it seems an equivalent function or library has not been brought into Metro/WinRT. If there is actually no equivalent function or library exposed in Metro/WinRT then that would make a custom text input box VERY difficult to bring to market in non-US countries. Specific example: in my custom control, if a french keyboard user presses the è,ù,é, or à keys, they are unable

Windows 8 store app c# animating margin [closed]

萝らか妹 提交于 2019-12-14 01:00:26
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . i am creating a windows store app and it needs some animation does anyone have a working example of animating the margin of an usercontrol? do i need to use reposition? ( doubleanimation doesn't support ucChat

Async: How to break on exact line of code that has thrown the exception?

ぃ、小莉子 提交于 2019-12-14 00:52:39
问题 Say I have the following code: async void buttonClick(object sender, RoutedEventArgs e) { await nested1(); } async Task nested1() { await nested2(); } async Task nested2() { await nested3(); } async Task nested3() { await Task.Delay(1000); throw new Exception("Die"); // <-- I want Visual Studio to break on this line } How can I make Visual Studio break on the indicated line only when the exception is unhandled ? Normally when the exception is thrown, Visual Studio will break here in App.g.i

Toast notifications only pop up if the app is being activated

落爺英雄遲暮 提交于 2019-12-13 21:21:30
问题 I have this problem with toast notifications, my app shows toast notifications only when it is activated (I.e: when I am using it). Here is my code for the toast notifications: private void ShowToastNotification(string text) { var xml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText01); xml.GetElementsByTagName("text")[0].AppendChild(xml.CreateTextNode(text)); ToastNotificationManager.CreateToastNotifier().Show(new ToastNotification(xml)); } My application is simply a