0603 -Notification InteractionRequest

InteractionRequest<INotification>

Prism通过InteractionRequest 来实现弹窗交互,它是一个泛型接口,不同的类型对应不同类型的弹窗方式。
 

Notification

在使用InteractionRequest的时候需要在,xaml中需要注册一个Trigger:

<i:Interaction.Triggers>

     <prism:InteractionRequestTrigger SourceObject="{Binding NotificationRequest}">

        <prism:PopupWindowAction IsModal="True" CenterOverAssociatedObject="True" />

     </prism:InteractionRequestTrigger>

</i:Interaction.Triggers>

那么i是什么呢?

interactivity这个是微软内置的类库,他提供了一组用户交互的类,比如我们这里用到的EventTrigger可以用来执行事件触发的操作。

在使用的时候,先引入xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"

或者xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity",然后在xaml中使用他:

<i:Interaction.Triggers>

 <i:EventTrigger>

   </i:EventTrigger>

</i:Interaction.Triggers>

而 prism:PopupWindowAction 的 IsModal=True意味着弹框不被关闭的时候,父窗体无法使用。我刚搜索了一下,这个词的翻译竟然“模态”。

在code-behind中声明,使用INotification类型:

public InteractionRequest<INotification> NotificationRequest { get; set; }

在command的回调函数中就可以使用NotificationRequest:

NotificationRequest.Raise(new Notification { Content = "Notification Message", Title = "Notification" }, r => Title = "Notified");

最后通过ConfirmationRequest.Raise()方法来实现调用弹窗,这里将Title修改为“Notified”。

Confirmation

<prism:InteractionRequestTrigger SourceObject="{Binding ConfirmationRequest}">

   <prism:PopupWindowAction IsModal="True" CenterOverAssociatedObject="True" />

</prism:InteractionRequestTrigger>

public InteractionRequest<IConfirmation> ConfirmationRequest { get; set; }

ConfirmationRequest.Raise(new Confirmation {Title = "Confirmation",Content = "Confirmation Message" },r => Title = r.Confirmed ? "Confirmed" : "Not Confirmed");

https://www.bbsmax.com/A/A2dmReOBze/

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值