如何从我的解决方案中的文件夹加载 WPF 中的页面
How to load a Page in WPF from a folder inside my solution
我有这个 Grid
里面有 Frame
:
<Grid Name="GridMain" Grid.Row="1">
<Frame Name="MyFrame"
NavigationUIVisibility="Hidden"
Source="home.xaml"/
</Grid>
现在这个 home.xaml
页面加载成功并且位于我的根解决方案中。
现在在我的解决方案中有一个名为 Pages
的文件夹。我想加载这个 Pages
文件夹中的另一个 Page
,所以我尝试这样做:
xmlns:pages="clr-namespace:MyApp.Pages"
<Grid Name="GridMain" Grid.Row="1">
<Frame Name="MyFrame"
NavigationUIVisibility="Hidden"
Source="{pages:home.xaml}"/>
</Grid>
但这不起作用。
我做错了什么?
将 Source
属性 设置为 Pages/home.xaml
:
<Frame Name="MyFrame"
NavigationUIVisibility="Hidden"
Source="Pages/home.xaml"/>
Source
属性 应该设置成 URI.
我有这个 Grid
里面有 Frame
:
<Grid Name="GridMain" Grid.Row="1">
<Frame Name="MyFrame"
NavigationUIVisibility="Hidden"
Source="home.xaml"/
</Grid>
现在这个 home.xaml
页面加载成功并且位于我的根解决方案中。
现在在我的解决方案中有一个名为 Pages
的文件夹。我想加载这个 Pages
文件夹中的另一个 Page
,所以我尝试这样做:
xmlns:pages="clr-namespace:MyApp.Pages"
<Grid Name="GridMain" Grid.Row="1">
<Frame Name="MyFrame"
NavigationUIVisibility="Hidden"
Source="{pages:home.xaml}"/>
</Grid>
但这不起作用。
我做错了什么?
将 Source
属性 设置为 Pages/home.xaml
:
<Frame Name="MyFrame"
NavigationUIVisibility="Hidden"
Source="Pages/home.xaml"/>
Source
属性 应该设置成 URI.