Prism.Interactivity 之 PopupWindowAction 用法简记
阅读原文时间:2023年07月11日阅读:1
  • PopupWindow通过InteractionRequestTrigger(EventTrigger的派生类)侦听目标对象(InteractionRequest类型)的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委托。

手机扫一扫

移动阅读更方便

阿里云服务器
腾讯云服务器
七牛云服务器

你可能感兴趣的文章