Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/323.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Don';在app.xaml.cs Windows Phone 8.1中没有激活的方法_C#_Xaml_Windows Phone 8.1_States - Fatal编程技术网

C# Don';在app.xaml.cs Windows Phone 8.1中没有激活的方法

C# Don';在app.xaml.cs Windows Phone 8.1中没有激活的方法,c#,xaml,windows-phone-8.1,states,C#,Xaml,Windows Phone 8.1,States,实际上,我正在开发一个应用程序,起初它是一个空白的Windows Phone应用程序8.1。我想用一个FileOpenPicker来实现这个应用程序,以便从设备上获取图片。在WP 8.1中,我必须使用OpenFilePicker的PickSingleFileAndContinue方法。因此,我在此处阅读了有关配置项目以处理Continue事件的信息:。其中一个步骤是在app.xaml.cs文件中实现OnActivated方法。但在我的app.xaml.cs中没有OnActivated方法。 我已

实际上,我正在开发一个应用程序,起初它是一个空白的Windows Phone应用程序8.1。我想用一个FileOpenPicker来实现这个应用程序,以便从设备上获取图片。在WP 8.1中,我必须使用OpenFilePicker的PickSingleFileAndContinue方法。因此,我在此处阅读了有关配置项目以处理Continue事件的信息:。其中一个步骤是在app.xaml.cs文件中实现OnActivated方法。但在我的app.xaml.cs中没有OnActivated方法。

我已从上面的链接复制粘贴该方法,但该方法中使用的MainPage对象没有当前状态:

 protected async override void OnActivated(IActivatedEventArgs e)
    {
        base.OnActivated(e);

        continuationManager = new ContinuationManager();

        Frame rootFrame = CreateRootFrame();
        await RestoreStatusAsync(e.PreviousExecutionState);

        if (rootFrame.Content == null)
        {
            rootFrame.Navigate(typeof(MainPage));
        }

        var continuationEventArgs = e as IContinuationActivatedEventArgs;
        if (continuationEventArgs != null)
        {
            Frame scenarioFrame = MainPage.Current.FindName("ScenarioFrame") as Frame;
            if (scenarioFrame != null)
            {
                // Call ContinuationManager to handle continuation activation
                continuationManager.Continue(continuationEventArgs, scenarioFrame);
            }
        }

        Window.Current.Activate();
    }

正如我对Windows Phone所知,我只是面对一个应用程序的状态管理,我真的不知道这个错误是从哪里来的。也许有人有主意了

除非您从该链接下载完整的源代码示例,否则它不会100%清晰。他们忽略了发布完整的示例(代码太多)。下载C#演示项目并查看它


正如您所看到的,这只是一个静态声明。

问题是我删除了MainPage.xaml页面,因为我不需要它。所以我明白有时候有一个空白页面是有用的,所以我创建了MainPage.xaml。我在App.xaml.cs上仍然得到了相同的错误,从而添加了静态主页声明:主页被突出显示,因为它没有“当前”组件…@HubertSolecki发布你的MainPage.xaml.cs(整个文件),除非发生了奇怪的事情,否则我看不到这种情况发生。或者您可以删除该文件并添加->新建项目->Visual C#->Windows Phone肖像页面。将其命名为MainPage.xaml
public sealed partial class MainPage : Page
{
    public static MainPage Current;        

    public MainPage()
    {
        this.InitializeComponent();            

        // This is a static public property that allows downstream pages to get a handle to the MainPage instance
        // in order to call methods that are in this class.
        Current = this;            

        Windows.Phone.UI.Input.HardwareButtons.BackPressed += HardwareButtons_BackPressed;
    }
}