我正在尝试使用 xaml 岛为我的 wpf 应用程序设置导航,但无法在视图之间导航。我收到一个错误:
frame does not contain a definition of SourcePageType
主窗口.cs:
private void On_Navigated(object sender, NavigationEventArgs e)
{
if (NavView.Child is NavigationView navigationView) {
// NavView.IsBackEnabled = ContentFrame.CanGoBack;
navView = navigationView;
if (ContentFrame.Content?.GetType() == typeof(SettingsPage))
{
// SettingsItem is not part of NavView.MenuItems, and doesn't have a Tag.
navView.SelectedItem = (NavigationViewItem)navView.SettingsItem;
navView.Header = "Settings";
}
else if (ContentFrame.Content != null)
{
var item = _pages.FirstOrDefault(p => p.Page == e.Content);
navView.SelectedItem = navView.MenuItems
.OfType<NavigationViewItem>()
.First(n => n.Tag.Equals(item.Tag));
navView.Header =
((NavigationViewItem)navView.Content)?.Content?.ToString();
}
}
}
我认为 NavView_Loaded 捕获所选项目的方法有问题吗?在 xaml 岛屿中是否有任何导航示例?
谢谢你