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

        }
相关推荐
可可西里_X_back2 分钟前
Linux学习(二)- 驱动开发步骤
linux·驱动开发·学习
dr_yingli2 分钟前
慢性肾脏病评估与管理临床实践指南 KDIGO 2024 CKD 诊断指标速查手册
笔记
GISer_Jing25 分钟前
测绘与GIS考试高频考点选择题精选
学习·arcgis
OBiO201341 分钟前
从单细胞多组学到体内验证:器官纤维化与代谢疾病的研究新范式
笔记·学习
小清兔3 小时前
Addressable的设置打包流程
笔记·游戏·unity·c#
Irene19913 小时前
PMP管理大数据学习建议
大数据·学习·pmp
谙弆悕博士3 小时前
Python快速学习——第8章:循环语句
python·学习·servlet
Tutankaaa4 小时前
知识竞赛计分如何确保绝对准确?双机热备方案详解与实施要点
笔记·学习·职场和发展
xiaoxiaoxiaolll4 小时前
Light: Sci & Appl. | 子阵列栅控HEMT超表面:太赫兹波前同时实现高速调制与物理层逻辑
学习
爱喝水的鱼丶4 小时前
SAP-ABAP:SAP 与 ABAP 关联逻辑与入门路径:业务×开发的协作指南
服务器·前端·数据库·学习·sap·abap