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

        }
相关推荐
Komorebi_99992 小时前
大模型学习day5
学习·大模型
逍遥德2 小时前
AI时代,计算机专业大学生学习指南
java·javascript·人工智能·学习·ai编程
网络与设备以及操作系统学习使用者2 小时前
直连路由优先级最高
运维·网络·学习·华为·智能路由器
码途漫谈3 小时前
Easy-Vibe高级开发篇阅读笔记(五)——CC教程之Agent Teams
人工智能·笔记·ai·开源·ai编程
逆羽飘扬4 小时前
【AI Infra面试】基础学习汇总篇
人工智能·学习
憧憬成为原神糕手4 小时前
FFmpeg 音视频开发笔记(一):H.264 解码为 YUV
笔记·ffmpeg·音视频
爱听歌的周童鞋4 小时前
Learn-Claude-Code | 笔记 | Collaboration | s11 Autonomous Agents
笔记·llm·agent·claude code·collaboration·autonomous
05候补工程师4 小时前
[线性代数] 判定线性相关性的“降维打击”:从基本定理到速通特殊法
经验分享·笔记·学习·线性代数·考研
太阳上的雨天5 小时前
AI学习ing~
学习·ai·ai编程
麦田里的粮仓5 小时前
文档站点生成器 - Fumadocs
学习