如何在WPF中修复导航/帧错误?错误#CS1061



我正在尝试设置一个内部框架的导航页面,我发现了这个错误,似乎无法摆脱。我的框架已经停止工作并显示我已连接到它们的页面。

我尝试查找此错误CS1061,并尝试查看错误在哪里。它似乎与mainwindow.xaml中的Navigated="Frame_Navigated冲突。也许有人可以指出我到底出了什么问题?它以前工作了。

mainwindow.xaml.cs代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace TataSteel_Gamification_01
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            //Display Items in Frame
            Loaded += Window_Loaded;
        }
        Boolean MenuToggle = true;
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            //Open the Start Frame
            frame.NavigationService.Navigate(new Page1());
        }
        private void Btn_Page1_Click(object sender, RoutedEventArgs e)
        {
            //Open Page 1
            frame.NavigationService.Navigate(new Page1());
        }

mainwindow.xaml代码(切出不辅助零件(:

<Window x:Name="ApplicationFrame" x:Class="TataSteel_Gamification_01.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:TataSteel_Gamification_01"
        mc:Ignorable="d"
        Title="MainWindow" Height="1200" Width="1920" Background="#FF1C2431">
<Grid x:Name="Grid_Display" ShowGridLines="False">
<Viewbox x:Name="Viewbox_Frame" Grid.Column="1" Grid.Row="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<Frame x:Name="frame" Content="Frame" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" NavigationUIVisibility="Hidden" Navigated="Frame_Navigated" Height="1170" Width="1435"/>
</Viewbox>
</Grid>

我希望结果后的导航再次工作,因此我可以在框架内显示页面而无需任何错误。

Navigated="Frame_Navigated"

frame_navigated是在实际导航时调用功能。无论如何,您似乎都没有在 mainwindow.xaml.cs

中实现它

这是.cs文件中缺少的内容:

private void Frame_Navigated(object sender, System.Windows.Navigation.NavigationEventArgs e)
{
 // your code to handle navigated frame
}

相关内容

  • 没有找到相关文章

最新更新