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. C盘扩展卷碰到的那些事-->不是同一块物理磁盘操作扩展卷是有坑的

    自己电脑上面用过win10系统资源管理器扩展卷的功能,用过几次都成功扩容了磁盘空间,简单说一下原理: 就是将剩余未分配的磁盘空间划给要扩展的磁盘. 这天公司的电脑C盘老是红色提示空间不足,那就扩充容量 ...

  2. Atcoder ABC388F Dangerous Sugoroku 题解 [ 蓝 ] [ 矩阵加速 ] [ 状压矩乘 ] [ 模拟 ]

    Dangerous Sugoroku:赛时写了矩乘 T 飞了,受到 sunkuangzheng 大佬的启发才知道要状压矩乘. 暴力矩乘思路 直接像过河那样写模拟细节非常多,于是考虑像美食家一样的思路, ...

  3. NebKit简介及工作流程

    引言 随着云计算技术的不断发展,容器化技术已成为现代软件开发和部署的重要组成部分.NebKit作为一个创新的容器编排和管理工具,旨在简化这一过程,提高开发效率和系统的可靠性.本文将对NebKit进行简 ...

  4. Linux - 安装JDK(.tar.gz)

    1.上传 jdk-8u351-linux-x64.tar.gz 到 /opt/module 目录下并解压 tar -zxvf jdk-8u351-linux-x64.tar.gz -C /opt/mo ...

  5. 【自荐】一款简洁、开源的在线白板工具 Drawnix

    在线白板工具 Drawnix -- 名字源于绘画(Draw)与凤凰(Phoenix)的灵感交织. Drawnix 的定位是一个开箱即用.开源.免费的在线白板工具产品, 集思维导图.流程图.画笔于一体, ...

  6. 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构

    概述 先看下面的图片,我们去旅游选择出行模式有很多种,可以骑自行车.可以坐汽车.可以坐火车.可以坐飞机. 作为一个程序猿,开发需要选择一款开发工具,当然可以进行代码开发的工具有很多,可以选择Idea进 ...

  7. DeepSeek+Claude强强联手,使用AI驱动DjangoStarter 3.1框架升级

    前言 上个月底培训了一周就没时间更新博客 上周有一些空闲时间,就继续体验最近很火的AI辅助编程 之前的文章中有说到我配置好了 VSCode + Cline 插件搭配本地部署的 DeepSeek 来实现 ...

  8. nginx 部署vue http、https

    nignx配置文件 server { listen 80; server_name your_domain.com; return 301 https://$server_name$request_u ...

  9. MongoDB入门介绍与案例分析

    一.MongoDB 数据库定位 首先我们来看一下 MongoDB 是什么样的数据库.数据库分两大类: OLTP(Online Transaction Processing)联机事务处理. OLAP(O ...

  10. linux ln命令详解

    介绍 ln是linux的一个重要命令,它的功能是为某一个文件在另外一个位置建立一个同步的链接.当我们需要在不同的目录,用到相同的文件时,我们不需要在每一个需要的目录下都放一个必须相同的文件,我们只要在 ...