WPF实战学习笔记20-设置首页启动页

文章目录

设置首页启动页

增加配置接口

添加接口文件:

Mytodo.Common/IConfigureInterface.cs

c# 复制代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Mytodo.Common
{
    public interface IConfigureInterface
    {
        void Configure();
    }
}

实现接口

MainViewmodel.cs

删除 CreatMenuBar();原位置的代码

c# 复制代码
        public void Configure()
        {
            CreatMenuBar();

            //导航到主页
            regionManager.Regions[PrismManager.MainViewRegionName].RequestNavigate("IndexView");
        }

配置启动选项

App.xmal.cs 重写OnInitialized方法

c# 复制代码
        protected override void OnInitialized()
        {
            var service = App.Current.MainWindow.DataContext as IConfigureInterface;

            if (service != null)
            {
                service.Configure();
            }

            base.OnInitialized();

        }
相关推荐
齐生110 小时前
iOS 知识点 - 渲染机制、动画、卡顿小集合
笔记
用户9623779544817 小时前
VulnHub DC-1 靶机渗透测试笔记
笔记·测试
齐生12 天前
iOS 知识点 - IAP 是怎样的?
笔记
tingshuo29172 天前
D006 【模板】并查集
笔记
tingshuo29173 天前
S001 【模板】从前缀函数到KMP应用 字符串匹配 字符串周期
笔记
Scout-leaf7 天前
WPF新手村教程(三)—— 路由事件
c#·wpf
西岸行者8 天前
学习笔记:SKILLS 能帮助更好的vibe coding
笔记·学习
starlaky8 天前
Django入门笔记
笔记·django
勇气要爆发8 天前
吴恩达《LangChain LLM 应用开发精读笔记》1-Introduction_介绍
笔记·langchain·吴恩达
悠哉悠哉愿意8 天前
【单片机学习笔记】串口、超声波、NE555的同时使用
笔记·单片机·学习