C# 如何在WPF c中运行页面?
我想做这样的事情,但是没有XAML,只有CC# 如何在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"
<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() } });
}