Prism.Interactivity 之 PopupWindowAction 用法简记

  • 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委托。
posted @ 2015-10-26 23:55  无眠0007  阅读(1675)  评论(0编辑  收藏  举报