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

        }
相关推荐
笨鸟先飞的橘猫7 分钟前
skynet热更新实现问题与排错记录
学习·lua·skynet
andrsted14 分钟前
练题簿在线免费刷题:将资料、Word 和 PDF导入小程序练习
学习·微信小程序·小程序·pdf·word·学习方法
新手小新17 分钟前
通信工程师学习笔记5-通信系统
笔记·学习
我命由我1234520 分钟前
刚性防水与柔性防水
学习·职场和发展·产品运营·求职招聘·职场发展·学习方法·产品
dtq042422 分钟前
C++3 - 分支语句if和string变量
开发语言·c++·学习
承渊政道36 分钟前
Linux网络学习【深入理解应用层HTTP协议、Cookie与Session机制及HTTPS协议原理】
linux·网络·学习·http·cookie·session
鸽芷咕37 分钟前
把 SQL 编辑器用顺:KSQL Developer 从补全到事务的实战笔记
笔记·sql·编辑器
LuminousCPP1 小时前
数据库学习笔记(二):MySQL 基础操作入门|在 CentOS Stream 10 上连接、建库与建表
数据库·经验分享·笔记·学习·mysql·centos
艾莉丝努力练剑1 小时前
【AI大模型接入SDK】ChatServer接口实现
c++·人工智能·学习·ai·架构·大模型·sdk
lhh_qrsly4 小时前
HTTP / HTTPS / MQTT / MQTTs(嵌入式学习版)
学习·http·https