Created
April 27, 2012 18:59
-
-
Save khmylov/2511876 to your computer and use it in GitHub Desktop.
Cleaned up WP7 App.xaml template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Application | |
x:Class="$namespace$.App" | |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |
xmlns:system="clr-namespace:System;assembly=mscorlib" | |
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone" | |
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"> | |
<Application.Resources> | |
<system:String x:Key="ApplicationTitle">APPLICATION TITLE</system:String> | |
<!-- Page margins --> | |
<Thickness x:Key="PageHeaderPanelMargin">12,17,0,28</Thickness> | |
<Thickness x:Key="PageNameLabelMargin">9,-7,0,0</Thickness> | |
<Thickness x:Key="PageContentPanelMargin">12,0</Thickness> | |
<Style x:Key="DefaultPageStyle" TargetType="phone:PhoneApplicationPage"> | |
<Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilyNormal}"/> | |
<Setter Property="FontSize" Value="{StaticResource PhoneFontSizeNormal}"/> | |
<Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/> | |
<Setter Property="SupportedOrientations" Value="Portrait"/> | |
<Setter Property="Orientation" Value="PortraitUp"/> | |
<Setter Property="shell:SystemTray.IsVisible" Value="True"/> | |
</Style> | |
</Application.Resources> | |
<Application.ApplicationLifetimeObjects> | |
<shell:PhoneApplicationService /> | |
</Application.ApplicationLifetimeObjects> | |
</Application> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Diagnostics; | |
using System.Windows; | |
using System.Windows.Navigation; | |
using Microsoft.Phone.Controls; | |
using Microsoft.Phone.Shell; | |
namespace TrackYourKids.Phone | |
{ | |
public partial class App | |
{ | |
public static new App Current | |
{ | |
get { return (App) Application.Current; } | |
} | |
public PhoneApplicationFrame RootFrame { get; private set; } | |
public App() | |
{ | |
UnhandledException += OnUnhandledException; | |
InitializeComponent(); | |
InitializePhoneApplication(); | |
InitializeDebugEnvironment(); | |
} | |
[Conditional("DEBUG")] | |
private void InitializeDebugEnvironment() | |
{ | |
if (Debugger.IsAttached) | |
{ | |
Application.Current.Host.Settings.EnableFrameRateCounter = true; | |
PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled; | |
} | |
} | |
private void OnNavigationFailed(object sender, NavigationFailedEventArgs e) | |
{ | |
if (Debugger.IsAttached) | |
{ | |
Debugger.Break(); | |
} | |
} | |
private void OnUnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e) | |
{ | |
if (Debugger.IsAttached) | |
{ | |
Debugger.Break(); | |
} | |
} | |
private void InitializePhoneApplication() | |
{ | |
RootFrame = new PhoneApplicationFrame(); | |
RootFrame.Navigated += CompleteInitializePhoneApplication; | |
RootFrame.NavigationFailed += OnNavigationFailed; | |
} | |
private void CompleteInitializePhoneApplication(object sender, NavigationEventArgs e) | |
{ | |
RootFrame.Navigated -= CompleteInitializePhoneApplication; | |
RootVisual = RootFrame; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Added
PhoneApplicationService
asApplication.ApplicationLifetimeObjects
to prevent null reference exception during debugging.