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

        }
相关推荐
sxlishaobin2 小时前
Maven Setting详解
java·学习·maven
每月一号准时摆烂2 小时前
服务器运维笔记(一)——使用shell编写实时查看BMC功率的脚本
运维·服务器·笔记
柳鲲鹏1 天前
内斗学概论:43、平级内斗
笔记
星恒随风1 天前
MySQL 从零入门(四):表的增删改查与基础查询详解
linux·服务器·数据库·笔记·mysql
li星野1 天前
相位补偿学习记录:把被颅骨“打乱“的声波重新对齐
学习
Z21-X1 天前
云原生运维学习笔记:ECShop全链路容器化部署与Docker底层资源隔离深度剖析
运维·笔记·学习·云原生
red_redemption1 天前
自由学习记录(230)
学习
晓梦林1 天前
BUUCTF-菜刀流量-MISC-学习笔记
笔记·学习
Godspeed Zhao2 天前
从零开始学AI25——无监督学习之层次聚类
学习·机器学习·聚类
David猪大卫2 天前
【C++修炼】map 和 set 的使用
c语言·开发语言·数据结构·c++·经验分享·笔记·学习