Skip to content

Instantly share code, notes, and snippets.

@LucasMoffitt
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LucasMoffitt/9012348 to your computer and use it in GitHub Desktop.
Save LucasMoffitt/9012348 to your computer and use it in GitHub Desktop.
Prism / MVVM App.cs
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