Logo
PREGNANCY
Windows XP
Windows Vista
Windows 7
Windows Azure
Windows Server
Windows Phone
 
 
Windows Phone

Windows Phone 8 : Developing for the Phone - The Phone Experience (part 4) - Understanding Idle Detection, The Tilt Effect

6/16/2013 5:23:56 PM

5. Understanding Idle Detection

The Windows Phone operating system automatically detects when a user has stopped using the phone and locks it. The phone will go to a lock screen, which can either display a pass code to open the lock screen or just instruct the user to slide up the wallpaper screen to get back to the phone.

Sometimes when you’re building certain types of applications, you want your application to continue to run regardless of whether the phone has input. There are two types of idle detection modes: application and user.

The easier of these to understand is the user idle detection mode. On the PhoneApplicationService class is a property called UserIdleDetectionMode; it is enabled by default. This means that if no touch events are detected, it will let the phone go to the lock screen. You can change this behavior (to enable your application to continue to run as the main running application even if the user isn’t interacting with your application) by disabling this detection mode, like so:

// Allow application to stay in the foreground
// even if the user isn't interacting with the application
PhoneApplicationService.Current.UserIdleDetectionMode =
  IdleDetectionMode.Disabled;

Disabling the user idle detection mode is useful when you are doing things that engage the user but do not require input (for example, showing a video, displaying a clock, and so on).

In contrast, the application idle detection mode is not about preventing the lock screen but determining what the application should do when the lock screen is enabled. By default, the application idle detection mode is enabled, which means that when the lock screen appears the application is paused (as though it was being tombstoned). By disabling the application idle detection mode, you allow your application to continue to run under the lock screen. To disable the application idle detection mode, you also use the PhoneApplicationService class:

// Allow your application to continue to run
// when the lock screen is shown
PhoneApplicationService.Current.ApplicationIdleDetectionMode =
  IdleDetectionMode.Disabled;

6. The Tilt Effect

In many places on the phone, a subtle but effective feedback mechanism is employed when selecting items in a list or other controls. This is called the tilt effect. In Figure 5, you can see that the second item in the list is not being interacted with via touch; however, in Figure 6 you can see that the second item is subtly tilted to give the user feedback that she is touching the item. In fact, it’s hard to see here in static images, but the tilt actually interacts with where the user is touching the item.

Image

FIGURE 5 Untilted

Image

FIGURE 6 Tilted

Unfortunately, this effect is not built into the framework, but it is available in the Windows Phone Toolkit. When you include the Toolkit’s XML namespace declaration in your XAML file, you can specify it at any level to enable or disable this behavior. The namespace required is the same one that is used to include Windows Phone Toolkit controls . Typically you would include it at the page level to support the tilt effect in all controls, like so:

<phone:PhoneApplicationPage ...
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;
                   assembly=Microsoft.Phone.Controls.Toolkit"
    toolkit:TiltEffect.IsTiltEnabled="True">

The TiltEffect.IsTiltEnabled property can be applied to any individual control as well if you want to apply the effect to specific controls instead of at the page or container levels. The other attached property is TiltEffect.SuppressTilt. This attached property enables you to turn off the tilt effect on particular controls where the TiltEffect.IsTiltEnabled attached property is enabled at a higher level. For example:

<Grid x:Name="ContentPanel"
      Grid.Row="1"
      Margin="12,0,12,0"
      toolkit:TiltEffect.IsTiltEnabled="False">
  <ListBox FontSize="28"
            Name="listBox1"
            toolkit:TiltEffect.SuppressTilt="True"
            ItemsSource="{Binding}" />
</Grid>

Because these are attached properties, you can set them in code as well:

using Microsoft.Phone.Controls;

public partial class MainPage : PhoneApplicationPage
{
  // Constructor
  public MainPage()
  {
    InitializeComponent();

    listBox1.SetValue(TiltEffect.SuppressTiltProperty, false);
  }
}

Other -----------------
- Windows Phone 8 : Developing for the Phone - Application Lifecycle (part 3) - Tombstoning
- Windows Phone 8 : Developing for the Phone - Application Lifecycle (part 2) - Navigation
- Windows Phone 8 : Developing for the Phone - Application Lifecycle (part 1)
- Windows Phone 8 : Designing for the Phone - Implementing the Look and Feel of the Phone
- Windows Phone 8 : Designing for the Phone - Designing with Visual Studio
- Windows Phone 7 : 3D Game Development (part 4) - Rendering 3D Models
- Windows Phone 7 : 3D Game Development (part 3) - The Game Class
- Windows Phone 7 : 3D Game Development (part 2) - Rendering 3D Primitives
- Windows Phone 7 : 3D Game Development (part 1) - 3D Game Concepts
- Windows Phone 8 : Phone-Specific Design (part 3) - Using the Pivot Control in Blend
- Windows Phone 8 : Phone-Specific Design (part 2) - Using the Panorama Control in Blend
- Windows Phone 8 : Phone-Specific Design (part 1) - The ApplicationBar in Blend
- Windows Phone 7 : AlienShooter Enhancements (part 2) - Tombstone Support, Particle System
- Windows Phone 7 : AlienShooter Enhancements (part 1) - Load and Save Game State
- Windows Phone 7 Programming Model : Application Execution Model
- Windows Phone 7 Programming Model : Bing Maps Control
- Windows Phone 8 : Designing for the Phone - Blend Basics (part 4) - Working with Behaviors
- Windows Phone 8 : Designing for the Phone - Blend Basics (part 3) - Creating Animations
- Windows Phone 8 : Designing for the Phone - Blend Basics (part 2) - Brushes
- Windows Phone 8 : Designing for the Phone - Blend Basics (part 1) - Layout
 
 
Most view of day
- Sharepoint 2013 : Service Application Fundamentals (part 2) - The Connection Structure - Tying It Up with an Example
- SharePoint 2013 : Health and Monitoring (part 2) - Correlation IDs, The Logging Database
- Windows Phone 8 : Messaging - Composing a New Message (part 3) - Sending a Picture from the Camera
- Microsoft Systems Management Server 2003 : Custom SMS Administrator Consoles
- Microsoft Lync Server 2013 : Office 365 and Lync Online - System Requirements
- Maintaining Desktop Health : Understanding Windows Error Reporting (part 1) - Error Reporting Cycle, Report Data Overview
- Microsoft Visio 2010 : Importing Graphics (part 2) - Using Images as Shapes in Visio - Handling Bitmaps and Jaggies
- Windows Server 2012 : Administering Active Directory using Windows PowerShell (part 1) - Managing user accounts with Windows PowerShell
- Sharing Your Computer with Others : Create a User Account, Switch Between Accounts
- Windows Phone 8 : Orientation and the PhoneApplicationPage Class (part 3) - Setting Page Orientation at Runtime
Top 10
- Microsoft LynServer 2013 : Windows Client - Conferencing (part 3) - Scheduling a Meeting
- Microsoft LynServer 2013 : Windows Client - Conferencing (part 2) - Changing the Layout, Customizing Meeting Options
- Microsoft LynServer 2013 : Windows Client - Conferencing (part 1) - Using the Meet Now Function, Controlling a Meeting, Managing Meeting Content
- Microsoft LynServer 2013 : Windows Client - Peer-to-Peer Conversations (part 2) - Making Audio Calls, Making Video Calls
- Microsoft LynServer 2013 : Windows Client - Peer-to-Peer Conversations (part 1) - Using Tabbed Conversations
- Microsoft Exchange Server 2013 : Working with cmdlets (part 2) - Understanding cmdlet errors, Using cmdlet aliases
- Microsoft Exchange Server 2013 : Working with cmdlets (part 1) - Using Windows PowerShell cmdlets, Using cmdlet parameters
- Microsoft Exchange Server 2013 : Using Windows PowerShell (part 2) - Running and using cmdlets, Running and using other commands and utilities
- Microsoft Exchange Server 2013 : Using Windows PowerShell (part 1) - Running and using Windows PowerShell
- Troubleshooting Stop Messages : Being Prepared for Stop Errors - Prevent System Restarts After a Stop Error
 
Windows XP
Windows Vista
Windows 7
Windows Azure
Windows Server
Windows Phone
2015 Camaro