July 2012 Blog Posts
Thursday, July 5, 2012 1:31 PM | Comments

On a recent project I needed to extract the windows phone user-agent string for our usage analytics, and it had to be the same user-agent as the IE requests. While this didn’t end up being as straight forward and I had hoped, the code below involves a few simple steps. First we have to insert a collapsed browser onto the page, then we can navigate it to specifically crafted HTML/JavaScript, which will in-turn notify the WebBrowser control of it’s user-agent. All you need to do is store it somewhere; in my case, I put it into a custom ApplicationSettings class, but you can store it anywhere you want. Usage Since this code requires adding a WebBrowser control to a page, it’s probably easier to do in code-behind as opposed to a view model. public partial class HomeView : PhoneApplicationPage { public HomeView() ...

Monday, July 2, 2012 12:12 PM | Comments

I’m currently wrapping up a Windows Phone project and thought this would be a good time to share some of the more reusable stuff we needed. Zebra-striping alternate rows This particular app displays a lot of tabular data, so we wanted to zebra-stripe the rows to make them easier to discern. At first we tried using a ValueConverter to get the index of the current container, but this method didn’t end up working with the Telerik DataBoundListBox. Instead, we wrote a simple IndexingObservableCollection that will automatically populate the Index of each item as it’s added to the collection. This method also works with the infinite scrolling feature of Telerik’s listbox – which we actually needed anyway. IndexingObservableCollection To use it, you have to implement the IIndexable interface which ensure an Index property on your model. Then simply replace the ObservableCollection property on your view-model with the following IndexingObservableCollection.public class...