WPF 模块工具栏棱镜 [英] WPF Module toolbar prism

查看:64
本文介绍了WPF 模块工具栏棱镜的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以提供有关如何填充导航工具栏的提示,该导航工具栏类似于 Billy Hollis 视频在应用底部显示的 StaffLynx 实体工具栏?

Can anyone provide a hint on how I would populate a navigation toolbar similar to the StaffLynx Entity toolbar that the Billy Hollis video displays across bottom of the app?

如果正在运行的应用程序版本确实加载了客户端模块并且可用,但我不确定如何执行这种 MVVM 样式,我只想在工具栏中显示一个客户端"图标?

I only want to show a "Client" icon in the toolbar if indeed the application version running has the Client module loaded and available but am unsure how to perform this MVVM style?

谢谢

推荐答案

你想要的是你的工具栏有一个区域:

What you want is your toolbar to have a region:

<controls:MyToolbar Prism:RegionManager.RegionName="ToolbarRegion" />

然后确保您的工具栏类型有一个有效的RegionAdapter;您可以在引导程序中覆盖 ConfigureRegionAdapterMappings 以注册其他区域适配器:

Then ensure there is a valid RegionAdapter for the type of your toolbar; You can override ConfigureRegionAdapterMappings in your bootstrapper to register additional region adapters:

protected override RegionAdapterMappings ConfigureRegionAdapterMappings()
{
    var mappings = base.ConfigureRegionAdapterMappings();

    var toolbarAdapter = Container.Resolve<MyToolbarRegionAdapter>();
    mappings.RegisterMapping(typeof (MyToolbar), toolbarAdapter);
}

然后在您的模块中,您可以注册要在该区域显示的视图,例如:

Then in your modules, you can register views to display in this region, e.g:

public class ModuleA : IModule
{
    private readonly IRegionManager _regionManager;

    public ModuleA(IRegionManager regionManager)
    {
        _regionManager = regionManager;
    }

    public void Initialize()
    {
        _regionManager.RegisterViewWithRegion("ToolbarRegion", typeof(MyToolbarItem));
    }
}

其中 MyToolbarItem 是您希望在工具栏中显示的视图.

Where MyToolbarItem is the view you want to be displayed in the toolbar.

Prism 然后会自动实例化 MyToolbarItem 的一个实例并将其添加到名为 ToolbarRegion 的区域.

Prism will then automatically instantiate an instance of MyToolbarItem and add it to the region called ToolbarRegion.

这篇关于WPF 模块工具栏棱镜的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆