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

        }
相关推荐
TL滕32 分钟前
从0开始学算法——第八天(堆排序)
笔记·学习·算法·排序算法
崇山峻岭之间33 分钟前
C++ Prime Plus 学习笔记030
c++·笔记·学习
关关长语39 分钟前
HandyControl 3.5.x 版本 ListViewItem不显示问题
windows·wpf
Macbethad1 小时前
工业设备维护程序技术方案
wpf
Macbethad1 小时前
工业设备配方管理系统技术方案
wpf
代码游侠1 小时前
数据结构——哈希表
数据结构·笔记·学习·算法·哈希算法·散列表
闲聊MoonL2 小时前
Microsoft Azure Cobalt 200 Launched with 132 Arm Neoverse V3 Cores
笔记
van久2 小时前
.Net Core 学习:DbContextOptions<T> vs DbContextOptions 详细解析
java·学习·.netcore
HalvmånEver2 小时前
Linux:进程替换(进程控制四)
linux·运维·服务器·学习·进程
van久2 小时前
.NET Core 学习第一天:Razor Pages应用介绍及目录结构
学习