Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/14.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# 如何在WPF c中运行页面?_C#_Wpf_Xaml - Fatal编程技术网

C# 如何在WPF c中运行页面?

C# 如何在WPF c中运行页面?,c#,wpf,xaml,C#,Wpf,Xaml,我想做这样的事情,但是没有XAML,只有C <Page x:Class="Mynamespace.MyPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:Mynamespace"

我想做这样的事情,但是没有XAML,只有C

<Page x:Class="Mynamespace.MyPage"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:Mynamespace"
        Title="MyPage"
        Height="350"
        Width="525">
       <DockPanel>
            <...>

            </...>
        </DockPanel>
</Page>
我希望我的应用程序运行该页面。但Application.Run仅适用于windows。如何让我的应用程序运行页面


谢谢你的时间

您可以简单地执行以下操作:

public static void Main()
{
    Application app = new Application();
    app.Run(new Window() { Content = new Frame() { Content = new MyPage() } });
}
执行此操作时,您正在加载一个窗口,其中包含一个框架。在这个框架内会有你的页面

根据:

页面可以导航到Windows Internet Explorer、NavigationWindow和Frame并由其承载

emphasis mine

运行页面是什么意思?将页面添加到窗口
public static void Main()
{
    Application app = new Application();
    app.Run(new Window() { Content = new Frame() { Content = new MyPage() } });
}