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 分钟前
AI 工具推荐:AI绘图、AI助力学习
人工智能·学习
koo3648 分钟前
pytorch深度学习笔记5
pytorch·笔记·深度学习
wdfk_prog21 分钟前
[Linux]学习笔记系列 -- [fs]binfmt_script
linux·笔记·学习
走在路上的菜鸟28 分钟前
Android学Dart学习笔记第十二节 函数
android·笔记·学习·flutter
摇滚侠1 小时前
2025最新 SpringCloud 教程,熔断规则-熔断策略-异常数,笔记46
java·笔记·spring cloud
摇滚侠1 小时前
2025最新 SpringCloud 教程,熔断规则-熔断策略-慢调用比例,笔记44
java·笔记·spring cloud
找了一圈尾巴2 小时前
LLM-as-a-Judge-论文学习(中)
学习·模型评估
ECC&SM92 小时前
shell脚本使用笔记2
笔记
Ttang232 小时前
【AI学习1】了解开源大模型
人工智能·学习·开源
望忆2 小时前
关于《Contrastive Learning for Cold-Start Recommendation》的学习
学习