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

        }
相关推荐
sbc-study1 小时前
comsol仿真例题学习-模块-水平集+相场法
学习·comsol·例题·水平集·相场法·电镀
EchoL、1 小时前
Obsidian使用学习
笔记·学习
XFF不秃头2 小时前
力扣刷题笔记-旋转图像
c++·笔记·算法·leetcode
源之缘-OFD先行者2 小时前
全栈开发实战:WPF+FFmpeg+GIS,打造工业级雷达探测终端
ffmpeg·wpf
铜豌豆_Y2 小时前
【实用】GDB调试保姆级教程|常用操作|附笔记
linux·c语言·驱动开发·笔记·嵌入式
有为少年3 小时前
Welford 算法 | 优雅地计算海量数据的均值与方差
人工智能·深度学习·神经网络·学习·算法·机器学习·均值算法
shenghaide_jiahu3 小时前
数学分析简明教程——总练习题6
学习
石像鬼₧魂石3 小时前
HexStrike AI 理想操作流程清单(完整功能版)
linux·人工智能·windows·学习·ubuntu
wdfk_prog4 小时前
[Linux]学习笔记系列 -- [fs]file
linux·笔记·学习