Я предлагаю сохранить пароль в каком-либо (зашифрованном) постоянном хранилище и попытаться восстановить его при запуске приложения.
Затем добавьте этот код в App.xaml, и он должен добиться цели
void RootFrame_Navigating(object sender, NavigatingCancelEventArgs e)
{
// Only care about MainPage
if (e.Uri.ToString().Contains("/MainPage.xaml") != true)
return;
var password = GetPasswordFromSomePersistentStorage();
// Cancel current navigation and schedule the real navigation for the next tick
// (we can't navigate immediately as that will fail; no overlapping navigations
// are allowed)
e.Cancel = true;
RootFrame.Dispatcher.BeginInvoke(delegate
{
if (string.IsNullOrWhiteSpace(password))
RootFrame.Navigate(new Uri("/InputPassword.xaml", UriKind.Relative));
else
RootFrame.Navigate(new Uri("/ApplicationHome.xaml", UriKind.Relative));
});
}
Убедитесь, что вы добавили обработчик в конструктор App ()
RootFrame.Navigating += new NavigatingCancelEventHandler(RootFrame_Navigating);
А также, MainPage.xaml, это просто и пустая страница (настраиваемая на начальной странице), которая будет использоваться для перехвата исходного события навигации.
Надеюсь, это поможет.