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

        }
相关推荐
-To be number.wan15 分钟前
数据库系统 | 数据库安全与完整性
数据库·学习
czysoft1 小时前
se被限速
科技·学习·it·技术·魔法·先进·领先
子不语1801 小时前
从0开始学习S7-1200+ET200SP(3)——两台S7-1200通过TCP连接
网络协议·学习·tcp/ip
llllliznc2 小时前
LLM 学习笔记 Day 5:Agent 核心组件——Planner、Memory 与 Reflection
笔记·学习
risc1234562 小时前
“解决了什么痛点”与“为什么有这个东西”的关系?
笔记
hj2862512 小时前
Docker 容器化技术标准化笔记
java·笔记·docker
hyhsandy18032 小时前
STM32F103 TIM学习笔记
笔记·stm32·学习
栈溢出了2 小时前
Redis 消息队列笔记:List 与 Pub/Sub
redis·笔记·list
GuHenryCheng3 小时前
【ESP32】ESP-IDF开发环境搭建(cursor)
git·stm32·单片机·学习
鹰影473 小时前
一款AI笔记助手和远程同步的markdown笔记idea-note
人工智能·笔记·rust·typescript·react