Search

Monday, February 25, 2013

Windows Phone 8 Development Tips and Tricks


Change your application title as it appears on the phone app list

Go to the WMAppManifest.xml in the Properties folder and edit the Title attribute in the <App line or open it in the editor and update the title and other attributes

<?xml version="1.0" encoding="utf-8"?>
        <Deployment xmlns="http://schemas.microsoft.com/windowsphone/2012/deployment"
       <DefaultLanguage xmlns="" code="en-US"/>
        <App xmlns="" ProductID="{xxxxxxxxx}" Title="Your Product Name"

Stop the lock screen from popping up

PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;

Setup a menu with navigation to another page

// Set the page's ApplicationBar to a new instance and minimize it used when no buttons/icons are needed

       ApplicationBar = new ApplicationBar
       {
              Mode= ApplicationBarMode.Minimized,
};

ApplicationBarMenuItem menuItem = new ApplicationBarMenuItem(AppResources.Token);
ApplicationBar.MenuItems.Add(menuItem);
menuItem.Click += (s, ev) => { NavigationService.Navigate(new Uri("/Token.xaml", UriKind.Relative)); };

 Using geolocation (GPS) services
 
// Get a high accuracy watcher, usually called from a Dispatcher Timer so it won’t block the UI and be reset after a period (usually 15 minutes) of time
GeoCoordinateWatcher watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High);
// MovementThreshold is in meters
watcher.MovementThreshold = 100;
// Add event handlers for StatusChanged and PositionChanged events
watcher.PositionChanged += (s, ev) =>
{
       try
       {
              // Get the user's location
              latitude = ev.Position.Location.Latitude.ToString("00.00000");
              longitude = ev.Position.Location.Longitude.ToString("00.00000");
 
              // Stop the watcher because the method will be called again in 15 minutes
              watcher.Stop();
       }
       catch (Exception ex)
       {
       }
// Start data acquisition
watcher.Start();
}
 

No comments:

Post a Comment