Prism.Interactivity 之 PopupWindowAction 用法简记

来源:互联网 时间:1970-01-01


  • PopupWindow通过InteractionRequestTrigger(EventTrigger的派生类)侦听目标对象(InteractionRequest<T>类型)的Raised事件Show出来;
 <winInteractivity:Interaction.Triggers> <prism:InteractionRequestTrigger SourceObject="{Binding Path=EmployeePopupViewRequest,Mode=OneWay}"> <prism:PopupWindowAction IsModal="True" CenterOverAssociatedObject="True"> <prism:PopupWindowAction.WindowContent> <views:EmployeeView /> </prism:PopupWindowAction.WindowContent> </prism:PopupWindowAction> </prism:InteractionRequestTrigger> </winInteractivity:Interaction.Triggers>
  • PopupWindow实现IInteractionRequestAware接口,通过Action委托成员FinishInteraction关闭PopupWindow;
 public Action FinishInteraction { get; set; } public INotification Notification { get { return this.DataContext as INotification; } set { this.DataContext = value; } } private void CloseWindow() { if (this.FinishInteraction != null) this.FinishInteraction(); }
  • InteractionRequestedEventArgs(上述Raised事件的事件处理器的EventArgs)有两个只要成员,一个是INotification的派生类(将会作为PopupWindow的DataContext:即ViewModel),另一个是回调使用的Action委托。



相关阅读:
Top