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

        }
相关推荐
时光不去1 天前
java接口自动化之allure本地生成报告
运维·笔记·自动化
beyond谚语1 天前
第四章 依赖项属性
wpf
杨浦老苏1 天前
简单直观的笔记管理器Poznote
笔记·docker·群晖
椰壳也可1 天前
06_作业基于CubeMx实现按键控制LED灯(裸机)(立芯嵌入式笔记)
笔记·stm32·学习
im_AMBER1 天前
Leetcode 52
笔记·学习·算法·leetcode
菜鸟‍1 天前
【前端学习】阿里前端面试题
前端·javascript·学习
wdfk_prog1 天前
[Linux]学习笔记系列 -- [kernel]kallsyms
linux·笔记·学习
国服第二切图仔1 天前
鸿蒙应用开发之实现键值型数据库跨设备数据同步
数据库·wpf·harmonyos
!chen1 天前
CPP 学习笔记 语法总结
c++·笔记·学习
现在,此刻1 天前
李沐深度学习笔记D3-线性回归
笔记·深度学习·线性回归