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. 1.6~THUWC 的总结

    THUWC 虽然拿到了一等奖,但是其实不如预期的发挥. Day1 获得 260~300 分.快速地想出了 T1T2 然后在调试上花费了很多的时间,T3 没有想出来,T4 想出了 \(O(n\log^3 ...

  2. Sqoop1的导入导出

    Sqoop1 和 Sqoop2 的区别 # 版本上 Sqoop1: 1.4.x Sqoop2: 1.99.x # 架构上 Sqoop1 使用 Sqoop客户端直接提交的方式(命令.将命令封装在脚本中) ...

  3. 【Matlab】输出变量内容到xls文件

    版本: matlab 2017a 功能:将矩阵输出一个excel文件 代码: function [ statu ] = write2xls( x,filename,sheet) % 返回值: % 1 ...

  4. phpinclude-labs做题记录

    Level 1 file协议 payload:?wrappers=/flag Level 2 data协议 去包含data协议中的内容其实相当于进行了一次远程包含,所以data协议的利用条件需要 ph ...

  5. allure 报告空白

    在pycharm 运行py文件后生成的报告内容空白: 尝试方法 替换allure版本号---不好用 用命令生成.html测试报告,再以浏览器形式打开 ** ** 命令 allure generate ...

  6. 【Bug记录】node-sass安装失败解决方案

    node-sass 安装失败解决办法 前言 很多小伙伴在安装 node-sass 的时候都失败了,主要的原因是 node 版本和项目依赖的 node-sass 版本不匹配. 解决方案 解决方案:把项目 ...

  7. Pydantic多态模型:用鉴别器构建类型安全的API接口

    title: Pydantic多态模型:用鉴别器构建类型安全的API接口 date: 2025/3/20 updated: 2025/3/20 author: cmdragon excerpt: Py ...

  8. CentOS 7 下 Docker 的离线安装方法

    现遇到部分学校提供的服务器并没有外网连接,故需要在断网条件下安装 Docker ,本贴简述断网安装 Docker 的方法. 去 Docker 或者相关镜像源中下载 Docker RPM 包,以下链接的 ...

  9. docx4j转换pdf样式问题~Java Libreoffice转换pdf

    背景 本篇文章主要是介绍我在使用docx4j过程中遇到的问题,并最终如何通过Libreoffice来实现pdf的转换. 问题 在使用docx4j转换pdf过程中发现word文档中表格.加粗样式无法实现 ...

  10. List集合分页处理的方法

    参考https://www.cnblogs.com/cmz-32000/p/12186362.html 解决了数组越界问题 参数页码大于总页码时返回null(可根据自己业务调整为返回最后一页数据) s ...