我最近为wp7创建了一个应用程序。现在我准备好为我的应用程序提交更新。在我添加了UserControl页面(包含一个对话框)。我希望它显示在MainPage.xaml或应用启动中,但仅用于第一次应用启动。我知道如何首次展示MessageBox但不知道如何显示xaml页面。
if (!IsolatedStorageSettings.ApplicationSettings.Contains("IsFourthLaunchDone"))
{
MessageBox.Show("To Enable Full screen mode, go to settings and select Full Screen Browsing.");
IsolatedStorageSettings.ApplicationSettings["IsFourthLaunchDone"] = true;
}
有人可以帮我这个吗?在此先感谢您的帮助!
答案 0 :(得分:2)
以下是关于如何使用MessageBox正确完成此操作的想法。 App.xaml.cs:
public static bool IsFourthLaunch = false;
ApplicationLaunching(){
if (!IsolatedStorageSettings.ApplicationSettings.Contains("IsFourthLaunchDone"))
{
IsFourthLaunch = true;
}
}
MainPage.xaml.cs中:
MainPage()
{
if (App.isFourthLaunch)
{
Loaded += OnFourthLaunch;
}
}
public void OnFourthLaunch(object sender, RoutedEventArgs e)
{
Loaded -= OnFourthLaunch;
if (App.IsFourthLaunch)
{
MessageBox.Show("To Enable Full screen mode, go to settings and select Full Screen Browsing.");
IsolatedStorageSettings.ApplicationSettings["IsFourthLaunchDone"] = true;
App.IsFourthLaunch = false;
}
}
要使用UserControl执行此操作,请将控件添加到页面,最初使用折叠可见性。在要显示它的方案中,将可见性更改为Visible。您需要弄清楚Control希望以何种方式工作,并且您可能需要重写OnBackKeyPress以便为用户提供关闭控件的逻辑方式。
protected override void OnBackKeyPress( System.ComponentModel.CancelEventArgs e )
{
if (myControl.Visibility == Visibility.Visible)
{
e.Cancel = true;
myControl.Visibility = Visibility.Collapsed;
}
}