Windows Phone

Alternative to HttpClient for Windows Phone 7.5

If you wanted to move your WinRT project to support Windows Phone 7.5, you’ll rejoice at the recent news that Microsoft’s Microsoft.bcl.Async package in Nuget that allows using Async keywords and Task class but in the end, you really used them in WinRT because HttpClient class had a GetAsync method which is not available outside WinRT.

Worry not, the Microsoft.bcl.Async package comes with a Microsoft.Threading.Tasks.Extensions assembly that if you look inside, includes:

public static System.Threading.Tasks.Task<webresponse>GetResponseAsync(this System.Net.WebRequest source)
Member of AsyncExtensions</webresponse>

Which means you can use System.Net.WebRequest in its place and it supports Task/Async.

So you can do something like:

WebRequest request = WebRequest.Create(uri);
await request.GetResponseAsync();

How to Change Disabled Button Background, Focused TextBox Border etc in Windows Phone

In the properties tab or attributes of XAML, the level of control you can have over Silverlight controls is rather limited. You can’t change their behaviours in different states. To actually control it, you need to create a ControlTemplate. Sounds innocent enough but it’s basically forcing the user to redefine a user control and recreate the button or the textbox manually from their constituents (border, grid etc) which is extremely labour intensive if all you want to do is just change say the colour of the border when it is selected.

Instead of recreating the control from scratch, you can let Microsoft Expression Blend do some part of that job for you. Style your control to your liking as much as you can in Blend and then right-click to select Edit Template -> Edit a Copy. Then you get to define a key. Think of it like a CSS class and name it as you wish. Define it in the Application (App.xaml) so you can use it everywhere in your application. This will then generate a ControlTemplate for you based on the instance of control you selected Edit Template on. Read More…

 Scroll to top