Getting Started with IDialogAware

Creating dialogs with the DialogService requires a ViewModel that is IDialogAware. This special interface is what allows the DialogService to work with your ViewModel. Note that the navigation interfaces such as INavigationAwareIConfirmNavigationIInitializeIDestructible are not supported or used by the DialogService. By implementing IDialogAware you have methods that will allow you to do anything that you may be used to doing throught the ViewModel's lifecycle.

使用DialogService创建对话框需要一个IDialogAware的ViewModel。这个特殊的接口允许DialogService与ViewModel一起工作。注意,像INavigationAware, IConfirmNavigation, IInitialize, IDestructible这样的导航接口是不被DialogService支持或使用的。通过实现IDialogAware,你有了一些方法,这些方法将允许你在ViewModel的生命周期中做任何你可能习惯做的事情。

You can provide any specific logic you may want to prevent your dialog from closing. If RequestClose is invoked and CanCloseDialog returns false the Dialog Service will not close the Dialog.

您可以提供任何您想要阻止对话框关闭的特定逻辑。如果RequestClose被调用并且CanCloseDialog返回false,对话服务将不会关闭对话。

Sample Dialog View

Dialog's are built entirely from any Xamarin.Forms Layout or View. These all use normal bindings and might look something like the following:

对话框完全由Xamarin构建。窗体布局或视图。这些都使用普通绑定,可能看起来像下面这样

Registering the Dialog

Similar to registering a Page for Navigation, there is an extension on IContainerRegistry to register your Dialogs. You do not need to specify the ViewModel, as the ViewModelLocator will automatically attempt to resolve the ViewModel as long as both the Dialog and the ViewModel match Prism's naming/namespace conventions. Using the fully qualified registration method in which you specify both the Dialog View and the ViewModel is considered a better practice as this bypasses and Reflection cost that would be incurred by the ViewModelLocator.

类似于注册导航页面,在IContainerRegistry上有一个扩展来注册您的对话框。您不需要指定ViewModel,因为只要Dialog和ViewModel都符合Prism的命名/命名空间约定,ViewModelLocator就会自动尝试解析ViewModel。使用指定对话框视图和ViewModel的完全限定注册方法被认为是一种更好的实践,因为这绕过了ViewModelLocator可能产生的反射成本。

Using the Dialog Service

The Dialog Service is a very simplistic service which has a few overrides to make using it easier.

Dialog Service是一个非常简单的服务,它有一些覆盖,使它更容易使用

xamarin.forms+prism 实现DialogService(对话框服务)的更多相关文章

  1. .NET Core 3 WPF MVVM框架 Prism系列之对话框服务

     本文将介绍如何在.NET Core3环境下使用MVVM框架Prism的对话框服务,这也是prism系列的最后一篇完结文章,下面是Prism系列文章的索引: .NET Core 3 WPF MVVM框 ...

  2. Xamarin.Forms+Prism(1)—— 开发准备

    本次随笔连载,主要用于记录本人在项目中,用Xamarin.Forms开发APP中所使用的第三方技术或一些技巧. 准备: 1.VS2017(推荐)或VS2015: 2.JDK 1.8以上: 3.Xama ...

  3. Xamarin.Forms+Prism(3)—— 简单提示UI的使用

    这次给大家介绍两个比较好用的提示插件,如成功.等待.错误提示. 准备: 1.新建一个Prism Xamarin.Forms项目: 2.右击解决方案,添加NuGet包: 1)Acr.UserDialog ...

  4. LINKs: Xamarin.Forms + Prism

    LINK 1 - How to use Prism with Xamarin.Forms http://brianlagunas.com/first-look-at-the-prism-for-xam ...

  5. Xamarin.Forms+Prism(2)—— 基本使用 NavigationService 相对路径和绝对路径

    本文主要对Prism框架下的导航服务NavigationService进行一次介绍和使用. 1.打开VS,可以看到左侧的已安装模版里面有: 2.创建完成后,从PCL项目中,看到App.xaml.cs中 ...

  6. Xamarin.Forms + Prism,整理页面导航跳转流程

    3个Page,Page1 -> Page2 -> Page3 -> Page2 -> Page1. PageViewModel实现接口:INavigatingAware, IN ...

  7. Xamarin.Forms 开发资源集合(复制)

    复制:https://www.cnblogs.com/mschen/p/10199997.html 收集整理了下 Xamarin.Forms 的学习参考资料,分享给大家,稍后会不断补充: UI样式 S ...

  8. Xamarin.Forms 开发资源集合

    收集整理了下 Xamarin.Forms 的学习参考资料,分享给大家,稍后会不断补充: UI样式 Snppts: Xamarin Forms UI Snippets. Prebuilt Templat ...

  9. Xamarin.Forms开发APP

    Xamarin.Forms+Prism(1)—— 开发准备 准备: 1.VS2017(推荐)或VS2015: 2.JDK 1.8以上: 3.Xamarin.Forms 最新版: 4.Prism 扩展, ...

  10. Xamarin.Forms客户端第一版

    Xamarin.Forms客户端第一版 作为TerminalMACS的一个子进程模块,目前完成第一版:读取展示手机基本信息.联系人信息.应用程序本地化. 功能简介 详细功能说明 关于TerminalM ...

随机推荐

  1. Luogu P8710 [蓝桥杯 2020 省 AB1] 网络分析 题解 [ 绿 ] [ 带权并查集 ]

    原题 分析 本题由于从一个节点发信息,同一个集合内的所有点都会收到信息,显然是一道要求维护各节点间关系的题,因此采用并查集的数据结构进行求解. 但由于维护关系的同时还要维护权值,所以采用带权并查集,它 ...

  2. jenkins的admin用户的初始密码路径

    以下命令查看即可

  3. CTFHub技能树-信息泄露wp

    信息泄露 信息泄露(Information Disclosure)通常指题目中意外暴露了敏感数据或隐藏信息,这些信息可能直接或间接帮助解题者获取Flag 常见类型如下: HTTP请求 robots协议 ...

  4. flutter3-trip仿携程酒店预订|Flutter3.27+Getx预约旅游酒店App程序

    基于Flutter3.x+Dart3+GetX跨平台仿携程/飞猪旅行酒店客房预订查询app系统. flutter3_trip原创2025新版flutter3.27.1+dart3.6+getx+flu ...

  5. [联合省选 2020A] 组合数问题 题解

    后面有一只大大的组合数,考虑下降幂干过去.\(x^k\) 并不好使,这边考虑转化 \(f(x)=\sum a_ix^i=\sum b_ix^\underline i\). \[\sum_{k=0}^n ...

  6. python进行大乐透和双色球选号(LSTM预测和随机选号)

    文章仅供参考学习 1.LSTM预测 首先去爬取数据 这个是爬取大乐透的,从07年爬到最新一期 import requests from bs4 import BeautifulSoup import ...

  7. 基于Unity调取摄像头方式的定时抓拍保存图像方法小结

    上一篇<Maxmspjitter实现实时抓取摄像头画面并制成序列图 (定时抓拍)>已讲到了定时抓拍的相关问题解决方案,这一篇继续,采用不同的方法,不同的平台----基于Unity. 目标明 ...

  8. PDManer 入门教程:超强代码生成工具!

    PDManer 入门教程:超强代码生成工具!https://www.51cto.com/article/753161.html

  9. MySQL 中 DATETIME 和 TIMESTAMP 时间类型的区别及使用场景

    MySQL的日期类型简介 在 MySQL 中有两种存储时间的数据类型 DATETIME 和 TIMESTAMP,它们在数据库实际应用中,各有各的优势和劣势. 一. DATETIME 和 TIMESTA ...

  10. 关于普通程序员该如何参与AI学习的三个建议以及自己的实践

    大部分程序员在学习大语言模型的时候都比较痛苦,感觉AI是如此之近又如此之远,仿佛能搞明白一点,又好像什么也没明白.就像我们在很远的地方看珠穆拉玛峰,感觉它就像一个不大的山包,感觉只要自己做足准备咬咬牙 ...