Windows Phone 8.1 – Page Navigation

In Windows Phone 8.1, Page Navigation method is like this: Frame.Navigate(typeof(SecondPage), param); It means that you will navagate to ‘SecondPage’, and pass ‘param’ (a class based on object). If you needn’t to pass any parameters, You can use this: Frame.Navigate(typeof(SecondPage)); You can find the documentation for this MSDN link

Read text file in project folder in Windows Phone 8.1 Runtime

If you want to read a file from your project you can for example do it like this: string fileContent; StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(new Uri(@”ms-appx:///example.txt”)); using (StreamReader sRead = new StreamReader(await file.OpenStreamForReadAsync())) fileContent = await sRead.ReadToEndAsync(); Also please ensure that you have set the Build Action of your file as Content (it should be … Read more

Windows Phone 8.1 Toggling the visibility of a TextBlock in a DataTemplate

The problem I’m having is that I can’t access the TextBlock from the C# code. Yes, since the TextBlock is defined inside a DataTemplate, the TextBlock won’t be available until the DataTemplate has been applied. Thus, the x:Name attribute won’t automatically generate a variable reference in the InitializeComponent method in your *.g.i.cs file. (Read up … Read more

Photo capture on Windows Store App for Windows Phone

In WP8.1 Runtime (also in Silverlight) you can use MediaCapture. In short: // First you will need to initialize MediaCapture Windows.Media.Capture.MediaCapture takePhotoManager = new Windows.Media.Capture.MediaCapture(); await takePhotoManager.InitializeAsync(); If you need a preview you can use a CaptureElement: // In XAML: <CaptureElement x:Name=”PhotoPreview”/> Then in the code behind you can start/stop previewing like this: // start … Read more

Is it possible to update an existing Windows Phone 8 app to Windows Phone Store 8.1

TL;DR; – It preserves data on Isolated Storage when updating from WP8.0 to WP8.1 Runtime. Because the provided link to MSDN says only about Silverlight apps, and it’s not clear (if I hadn’t missed something) what would happen in case: I’ve old WP8.0 Silverlight App and now I decided to upgrade it to WP8.1 Runtime … Read more

ListBox items return string, when DataTemplate is Button

You need FrameworkTemplate.FindName Method (String, FrameworkElement) for this purpose: private childItem FindVisualChild<childItem>(DependencyObject obj) where childItem : DependencyObject { for (int i = 0; i < VisualTreeHelper.GetChildrenCount(obj); i++) { DependencyObject child = VisualTreeHelper.GetChild(obj, i); if (child != null && child is childItem) return (childItem)child; else { childItem childOfChild = FindVisualChild<childItem>(child); if (childOfChild != null) return childOfChild; } … Read more

How to POST using HTTPclient content type = application/x-www-form-urlencoded

var nvc = new List<KeyValuePair<string, string>>(); nvc.Add(new KeyValuePair<string, string>(“Input1”, “TEST2”)); nvc.Add(new KeyValuePair<string, string>(“Input2”, “TEST2”)); var client = new HttpClient(); var req = new HttpRequestMessage(HttpMethod.Post, url) { Content = new FormUrlEncodedContent(nvc) }; var res = await client.SendAsync(req); Or var dict = new Dictionary<string, string>(); dict.Add(“Input1”, “TEST2”); dict.Add(“Input2”, “TEST2”); var client = new HttpClient(); var req = … Read more

Windows Phone 8.1 Universal App terminates on navigating back from second page?

This is new to Windows Phone 8.1. If you create a new Hub Universal App using a VS2013 template, you’ll notice a class in Common folder called a NavigationHelper. This NavigationHelper gives you a hint how to properly react to back button press. So, if you don’t want to use the NavigationHelper, here’s how to … Read more