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

        }
相关推荐
丝斯20113 分钟前
AI学习笔记整理(56)——大模型微调
人工智能·笔记·学习
峥嵘life6 分钟前
Android16 EDLA【CTS】CtsNetTestCases存在fail项
android·java·linux·学习·elasticsearch
楼田莉子20 分钟前
Linux进程间通信——管道
linux·运维·服务器·c++·学习
理人综艺好会21 分钟前
Web学习之网络通信
学习
科技林总26 分钟前
【系统分析师】5.4 数据库设计与建模
学习
whale fall29 分钟前
【雅思-口语】与豆包聊天:出国旅游日常聊天英文 + 中文对照合集
笔记·学习·旅游
驱动探索者38 分钟前
Intel Xeon 服务器 CPU 学习
运维·服务器·学习·xeon
QiZhang | UESTC39 分钟前
学习日记day68
学习
暖阳之下39 分钟前
学习周报三十二
人工智能·学习
Das142 分钟前
【机器学习】10_特征选择与稀疏学习
人工智能·学习·机器学习