当前位置:网站首页>Prism framework project application - Navigation
Prism framework project application - Navigation
2022-06-26 03:44:00 【yuyue5945】
Prism Framework project application - Navigation
stay Prism in , Use Navigation It usually takes a few steps to jump between pages :
- Create a new page , And realize INavigationAware Interface
- Use IRegionManager Registration page
- Use NavigationParameters Encapsulate the parameters of page Jump
- Use IRegionManager.RequestNavigate() Jump to the target page
INavigationAware Interface
INavigationAware There are three interfaces ,IsNavigationTarget、OnNavigatedFrom、OnNavigatedTo It starts when you navigate the page , You can interface methods on demand , The code is as follows : Prism Base class page
The sample code is as follows
public class RegionViewModelBase : ViewModelBase, INavigationAware, IConfirmNavigationRequest
{
protected IRegionManager RegionManager {
get; private set; }
public RegionViewModelBase(IRegionManager regionManager)
{
RegionManager = regionManager;
}
public virtual void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
{
continuationCallback(true);
}
public virtual bool IsNavigationTarget(NavigationContext navigationContext)
{
return true;
}
public virtual void OnNavigatedFrom(NavigationContext navigationContext)
{
}
public virtual void OnNavigatedTo(NavigationContext navigationContext)
{
}
}
The navigated page can be inherited from RegionViewModelBase, The following code shows the rewriting OnNavigatedTo Method , stay OnNavigatedTo Starting from the related event method .
public class ViewAViewModel : RegionViewModelBase
{
private string _message;
public string Message
{
get {
return _message; }
set {
SetProperty(ref _message, value); }
}
public ViewAViewModel(IRegionManager regionManager, IMessageService messageService) :
base(regionManager)
{
Message = messageService.GetMessage();
}
public override void OnNavigatedTo(NavigationContext navigationContext)
{
//do something
}
}
Navigation code implementation
As shown in the following code , The navigation method is :RequestNavigate, Parameters include :( Area , source )
- The so-called region , That is, the page navigates to the area of the presentation page
- Source refers to , The name of the instantiated page
OnInitialized To initialize the module method
RegisterTypes To register project class methods
Both methods are executed automatically when the module is loaded . _regionManager.RequestNavigate(RegionNames.ContentRegion, “ViewA”); When the code indicates initialization , Navigation ViewA Page to main page ContentRegion Area .
public class ModuleNameModule : IModule
{
private readonly IRegionManager _regionManager;
public ModuleNameModule(IRegionManager regionManager)
{
_regionManager = regionManager;
}
/// <summary>
/// initialization
/// </summary>
/// <param name="containerProvider"></param>
public void OnInitialized(IContainerProvider containerProvider)
{
_regionManager.RequestNavigate(RegionNames.ContentRegion, "ViewA");
}
/// <summary>
/// Register the page into the container
/// </summary>
/// <param name="containerRegistry"></param>
public void RegisterTypes(IContainerRegistry containerRegistry)
{
containerRegistry.RegisterForNavigation<ViewA>();
}
}
边栏推荐
- 虫子 拷贝构造 运算符重载
- Cliquez sur le bouton action de la liste pour passer à une autre page de menu et activer le menu correspondant
- 【Appium踩坑】io.appium.uiautomator2.common.exceptions.InvalidArgumentException: ‘capabilities‘ are mand
- 路由跳转之点击列表的操作按钮,跳转至另一个菜单页面并激活相应的菜单
- Binary search
- 小程序或者for循序要不要加key?
- Solve the problem that the uniapp plug-in Robin editor reports an error when setting the font color and background color
- 链路监控 pinpoint
- Upload file / text / picture, box shadow
- 2022.6.20-----leetcode. seven hundred and fifteen
猜你喜欢
随机推荐
2022年挖财证券开户安全嘛?
虫子 拷贝构造 运算符重载
Kotlin quick start
[hash table] a very simple zipper hash structure, so that the effect is too poor, there are too many conflicts, and the linked list is too long
【Appium踩坑】io.appium.uiautomator2.common.exceptions.InvalidArgumentException: ‘capabilities‘ are mand
MySQL addition, deletion, query and modification (primary level)
Pay attention to the entrance components of official account in the applet
【好书集锦】从技术到产品
Is it safe for Caicai securities to open an account in 2022?
小米电视的网页和珠宝的网页
HL7Exception: Can‘t XML-encode a GenericMessage. Message must have a recognized struct
Evaluation - analytic hierarchy process
mysql存儲過程
816. 模糊坐标
Classic model alexnet
Request object, send request
虚拟化是什么意思?包含哪些技术?与私有云有什么区别?
MySQL addition, deletion, query and modification (Advanced)
Uni app, the text implementation expands and retracts the full text
todolist未完成,已完成








