ICommand以MVVM样式进行按钮按下和释放 - c#

我很高兴使用ICommand实现来处理按钮上的单个操作:

<Button Command="{Binding Path=ActionDown}">Press Me</Button>

通过ICommand实现RelayCommand

但是我找不到一种简单的方法来同时为新闻发布和发布提供动作(在SO上以及在其他网站上)。 IE浏览器,我想做这样的事情,但是我不知道该怎么做:

<Button PressCommand="{Binding Path=ActionDown}" ReleaseCommand="{Binding Path=ActionUp}">Press and Release Me</Button>

MVVM处理这种要求的正确方法是什么?

c#参考方案

您可以使用EventTrigger中的System.Windows.Interactivity来触发事件命令

<Button Content="Press Me">
    <i:Interaction.Triggers>
        <i:EventTrigger EventName="PreviewMouseLeftButtonDown">
            <i:InvokeCommandAction Command="{Binding Path=ActionDown}"/>
        </i:EventTrigger>
        <i:EventTrigger EventName="PreviewMouseLeftButtonUp">
            <i:InvokeCommandAction Command="{Binding Path=ActionUp}"/>
        </i:EventTrigger>
    </i:Interaction.Triggers>
</Button>

您需要添加对System.Windows.Interactivity的引用并定义名称空间

xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"

提交表单后显示模式对话框 - php

提交下载文件后,我有一张表格。我要自动而不是自动下载文件..以显示模态对话框并显示下载链接。<form name="softwareform" id="softwareform" action="../downloadlink.php" method="POST" alig…

DataSourceTransactionManager和JndiObjectFactoryBean和JdbcTemplate的用途是什么? - java

以下的用途是什么:org.springframework.jdbc.core.JdbcTemplate org.springframework.jdbc.datasource.DataSourceTransactionManager org.springframework.jndi.JndiObjectFactoryBean <tx:annotatio…

页面加载而不是提交时发生struts验证 - java

请原谅我;我对Struts有点陌生。我遇到一个问题,即页面加载而不是我实际提交表单时发生了验证。我整天都在论坛上搜寻和搜寻,没有任何运气。我显然做错了一些事情,应该很容易确定,但是我还没有发现问题所在。这是我的struts.xml的片段:<action name="*Test" method="{1}" clas…

将python scikit学习模型导出到pmml - python

我想将python scikit-learn模型导出到PMML。哪个python软件包最合适?我阅读了有关Augustus的内容,但是我无法使用scikit-learn模型找到任何示例。 python大神给出的解决方案 SkLearn2PMML是 JPMML-SkLearn命令行应用程序周围的薄包装。有关受支持的Scikit-Learn Estimator和…

如何使用PHP从动态输入字段捕获数组值? - javascript

我正在编写一个在线时间跟踪网页,允许用户将学习时间输入该系统。用户将首先输入名称,然后根据日期输入学习时间。一天中可能会有多个学习时间。以下是我第一页的编码,<head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"…