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();

        }
相关推荐
whyTeaFo1 小时前
GAMES202: Lecture 5: Real-Time Environment Mapping ppt笔记
笔记
欢欢李2 小时前
【LTE L3 笔记 54】PDSCH动态功控
笔记·无线通信·物理层·lte·空口协议
做cv的小昊3 小时前
【大模型算法自学笔记07】NLP基础知识(1.7 Embedding)
人工智能·笔记·算法·计算机视觉·自然语言处理·transformer·embedding
元器件BOM超人3 小时前
LM2577S-ADJ升压笔记:3.5V输入、52kHz开关的电路要点
笔记
叼烟扛炮4 小时前
[LangGraph] 学习笔记(047):Pydantic 写的 State 也不校验,并行分支还互相看不见
笔记·学习
小白的高手之路4 小时前
【LeetCode 热题 100】206. 反转链表|链表、迭代、递归(Python)
笔记·python·算法·leetcode·链表·职场和发展·力扣
qq_274475154 小时前
第 16 篇:类型检测方案汇总:typeof、instanceof、Object.prototype.toString、手写 isType
javascript·学习·原型模式
leo_厉锵4 小时前
JMeter 性能测试实操笔记
笔记·jmeter
凢en5 小时前
AMD-SAM(Resizable BAR)
笔记·嵌入式硬件·gpu算力
Brain 博览记5 小时前
给吗啡类镇痛药装上“光开关”:照一下开、再照一下关——Cell 冷冻电镜解析阿片效价切换
开发语言·网络·论文阅读·学习·php