赞
踩
这里以实现按钮打开A和打开B为例
首先创建ViewA和ViewB的页面
在App.xaml.cs中实现对页面的注册
protected override void RegisterTypes(IContainerRegistry containerRegistry)
{
containerRegistry.RegisterForNavigation<ViewA>("PageA");
containerRegistry.RegisterForNavigation<ViewB>();
}
在MainWindowViewModel中实现对区域内容的设置。以打开A为例,创建按钮,然后实现打开A的函数功能。
using Prism.Commands; using Prism.Mvvm; using Prism.Regions; using System; namespace BlankCoreApp1.ViewModels { public class MainWindowViewModel : BindableBase { private readonly IRegionManager regionManager; public DelegateCommand OpenACommand { get; private set; } public MainWindowViewModel(IRegionManager regionManager) { OpenACommand = new DelegateCommand(OpenA); this.regionManager = regionManager; } private void OpenA() { // 设置区域内容为PageA的内容 regionManager.RequestNavigate("ContentRegion", "PageA", param);
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。