Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/270.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
从WinJS应用程序打开C#/XAML视图_C#_Xaml_Winjs_Win Universal App - Fatal编程技术网

从WinJS应用程序打开C#/XAML视图

从WinJS应用程序打开C#/XAML视图,c#,xaml,winjs,win-universal-app,C#,Xaml,Winjs,Win Universal App,我目前正在尝试从Windows10UAP WinJS项目中的C#类打开XAML视图。 为此,我从javascript实例化了一个C#类,然后调用该类上的一个方法来加载XAML视图。 但是,当我调用CoreApplication.CreateNewView()时,它会触发一个异常,并显示消息“值不在预期范围内” 我想知道我是否做错了什么(我不习惯Windows 10应用程序),或者根本不可能在WinJS应用程序中打开XAML/C#view 下面是我用来调用C#代码的JS代码: 下面是引发异常的C代

我目前正在尝试从Windows10UAP WinJS项目中的C#类打开XAML视图。 为此,我从javascript实例化了一个C#类,然后调用该类上的一个方法来加载XAML视图。 但是,当我调用CoreApplication.CreateNewView()时,它会触发一个异常,并显示消息“值不在预期范围内”

我想知道我是否做错了什么(我不习惯Windows 10应用程序),或者根本不可能在WinJS应用程序中打开XAML/C#view

下面是我用来调用C#代码的JS代码:

下面是引发异常的C代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.ApplicationModel.Core;
using Windows.UI.Core;
using Windows.UI.ViewManagement;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

namespace CsCode
{
    public sealed class Class1
    {
        public async void loadXamlPage()
        {
            //throw "Value does not fall within the expected range." exception
            Windows.ApplicationModel.Core.CoreApplicationView newView = CoreApplication.CreateNewView();

            int newViewId = 0;
            await newView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                var frame = new Frame();
                frame.Navigate(typeof(MainPage1), null);
                Window.Current.Content = frame;
                newViewId = ApplicationView.GetForCurrentView().Id;
            });
            bool viewShown = await ApplicationViewSwitcher.TryShowAsStandaloneAsync(newViewId);

        }
    }
}

无法从处于相同状态的WinJS应用打开c#/XAML控件。如果你发现了什么,请告诉我。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.ApplicationModel.Core;
using Windows.UI.Core;
using Windows.UI.ViewManagement;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

namespace CsCode
{
    public sealed class Class1
    {
        public async void loadXamlPage()
        {
            //throw "Value does not fall within the expected range." exception
            Windows.ApplicationModel.Core.CoreApplicationView newView = CoreApplication.CreateNewView();

            int newViewId = 0;
            await newView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                var frame = new Frame();
                frame.Navigate(typeof(MainPage1), null);
                Window.Current.Content = frame;
                newViewId = ApplicationView.GetForCurrentView().Id;
            });
            bool viewShown = await ApplicationViewSwitcher.TryShowAsStandaloneAsync(newViewId);

        }
    }
}