WPF的Prism - 如何将CancelEventArgs发送到viewmodel?

时间:2017-02-22 08:07:35

标签: wpf prism

如何在窗口关闭时将CancelEventArgs发送到viewmodel?我尝试了以下方法,但CloseWindow命令方法始终接收CancelEventArgs参数为null。如何以棱镜方式获取CancelEventArgs viewmodel?

<!-- View-->
    <interactivity:Interaction.Triggers>
        <interactivity:EventTrigger EventName="Closing">
            <interactivity:InvokeCommandAction Command="{Binding CloseWindowCommand}"  />
        </interactivity:EventTrigger>
    </interactivity:Interaction.Triggers>

视图模型

CloseWindowCommand =  DelegateCommand<CancelEventArgs>.FromAsyncHandler(CloseWindow);

public async Task CloseWindow(CancelEventArgs args)
{
   //Do Stuff
}

1 个答案:

答案 0 :(得分:1)

你应该使用Prism自己的<?php $subtil=$_GET['subtil1']; $til=$_GET['til1']; $files = glob("images/image/$til/$subtil/*.*"); $count=count($files); for ($i=0; $i<$count; $i++) { echo "<div class='pitem entry item-w1 item-h1' style='padding: 15px;'>"; $image = $files[$i]; echo "<img src='".$image."' class='img-responsive' style='padding:20px;border:1px solid black;'>".""; echo "<br>"; echo"<span style='float: center;padding-top: 10px;'><button type='submit' onclick='myFunction()' name='submit' value='Send' class='btn btn-primary'>Delete</button></span>"; $detatil="delete.php?image=$image&til=$til&subtil=$subtil"; //echo $detatil; echo "</div>"; ?> <script> function myFunction() { var r=confirm("Do you want to leave page!"); if (r) { //write redirection code window.location = "<?php echo$detatil?>"; } else { //do nothing } //document.getElementById("demo").innerHTML = txt; } </script> <?php }//for loop end ?> 类:

InvokeCommandAction

属于Blend SDK的xmlns:prism="http://prismlibrary.com/" ... <interactivity:Interaction.Triggers> <interactivity:EventTrigger EventName="Closing"> <prism:InvokeCommandAction Command="{Binding CloseWindowCommand}" /> </interactivity:EventTrigger> </interactivity:Interaction.Triggers> 类不支持将InvokeCommandAction作为命令参数传递。