OctopusKing

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
  11 随笔 :: 0 文章 :: 0 评论 :: 7180 阅读

初学作为记录(事发场景):

  WPFDemo的程序集中,定义了一个Views文件夹,该文件夹放一些页面Page、UI层面的东西。用Frame空间做导航的时候,始终报一个错误   //   System.IO.IOException:“找不到资源“views.buttonstylepage.xaml”。”

代码:

复制代码
private void Page1_Click(object sender, RoutedEventArgs e)
        {
            if(((Button)sender).Name == "Page1")
            {
                MyFrame.Navigate(new Uri("Page1.xaml", UriKind.Relative));  //  为程序集中,文件夹之外的页面,可以找得到
            }
            else if(((Button)sender).Name == "Page2")
            {
                MyFrame.Navigate(new Uri("Views.ButtonStylePage.xaml", UriKind.Relative));  //  为文件夹内的页面,找不到
       } 
    }
复制代码

原因:

  就是文件夹访问页面,用的是 . 不是/,才导致出的错  "Views.ButtonStylePage.xaml"

结果:

  将代码改为:  MyFrame.Navigate(new Uri("Views/ButtonStylePage.xaml", UriKind.Relative));

posted on   八爪鱼~  阅读(315)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· DeepSeek在M芯片Mac上本地化部署
· 葡萄城 AI 搜索升级:DeepSeek 加持,客户体验更智能
点击右上角即可分享
微信分享提示