Last active
August 29, 2015 13:56
-
-
Save LucasMoffitt/9012348 to your computer and use it in GitHub Desktop.
Prism / MVVM App.cs
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
namespace MyApp | |
{ | |
sealed partial class App : MvvmAppBase | |
{ | |
private readonly UnityContainer _container = new UnityContainer(); | |
public App() | |
{ | |
InitializeComponent(); | |
} | |
protected override Task OnLaunchApplication(LaunchActivatedEventArgs args) | |
{ | |
AnalyticsHelper.Setup(); | |
NavigationService.Navigate("Main", null); | |
return Task.FromResult<object>(null); | |
} | |
protected override void OnInitialize(IActivatedEventArgs args) | |
{ | |
_container.RegisterInstance(SessionStateService); | |
_container.RegisterInstance(NavigationService); | |
_container.RegisterType<IDataService, DataService>(); | |
ViewModelLocator.SetDefaultViewModelFactory(viewModelType => _container.Resolve(viewModelType)); | |
} | |
protected override IList<SettingsCommand> GetSettingsCommands() | |
{ | |
return new List<SettingsCommand> | |
{ | |
new SettingsCommand("AboutUs", "About Us", command => NavigationService.Navigate("AboutUs", null)), | |
new SettingsCommand("PrivacyPolicy", "Privacy Policy", command => new PrivacyPolicyFlyout().Show()) | |
}; | |
} | |
} | |
} | |
namespace Microsoft.Practices.Prism.StoreApps | |
{ | |
public abstract class MvvmAppBase : Application | |
{ | |
protected MvvmAppBase(); | |
protected Func<SplashScreen, Controls.Page> ExtendedSplashScreenFactory { get; set; } | |
public bool IsSuspending { get; } | |
protected INavigationService NavigationService { get; set; } | |
protected ISessionStateService SessionStateService { get; set; } | |
protected virtual Type GetPageType(string pageToken); | |
protected virtual IList<global::Windows.UI.ApplicationSettings.SettingsCommand> GetSettingsCommands(); | |
[DebuggerStepThrough] | |
protected Task<Controls.Frame> InitializeFrameAsync(IActivatedEventArgs args); | |
protected virtual void OnInitialize(IActivatedEventArgs args); | |
protected abstract Task OnLaunchApplication(LaunchActivatedEventArgs args); | |
[DebuggerStepThrough] | |
protected override void OnLaunched(LaunchActivatedEventArgs args); | |
protected virtual void OnRegisterKnownTypesForSerialization(); | |
protected virtual object Resolve(Type type); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment