Command
을 할당 할 수 있도록하려는
Button
:MVVM : 버튼 홀드 이벤트 명령
Click
이벤트Command
보류 기간을 지정
HoldTimeout
속성을 사용Hold
이벤트 명령public static readonly DependencyProperty HoldCommandProperty = DependencyProperty.Register( "HoldCommand", typeof(ICommand), typeof(CommandButton), new PropertyMetadata(null, CommandChanged)); public ICommand HoldCommand { get { return (ICommand)GetValue(CommandProperty); } set { SetValue(CommandProperty, value); } }
클릭 & 보류 시간을 계산하는 방법과 계산은 어디에서 수행해야합니까? 단추의 '명령'속성을 사용하는 경우 Click 이벤트 처리가 올바른지 잘 모르겠습니다. 내가 더블 클릭을 구현하는 방법을 읽고
<CommandButton x:Name="InputButton"
Command="{Binding PrimaryCommand}"
CommandParameter="{Binding}"
HoldCommand="{Binding SecondaryCommand}"
HoldCommandParameters="{Binding}"
HoldTimeout="2000"/>
하지만이 정확히되지 않습니다 : :
결과의 XAML 그렇게 보일 것이다
- http://brianseekford.com/index.php/2010/08/31/mouse-double-click-for-wpf-in-mvvm-using-a-clean-behavior-with-command-binding/
- How can I bind a Hold/DoubleTap event of a button to a property in ViewModel합니다.
완벽한 솔루션을 제공해 주셔서 감사합니다. 하나의 작은 점은 두 개의 다른 명령을 사용할 수 있어야한다는 것입니다. 하나는 클릭이고 다른 하나는 보류입니다. –
다른 명령 인 "ClickAndHoldCommand"를 SmartButton에 추가했습니다. 이 명령에 명령을 바인드하고 각 특성을 사용 가능하게해야합니다. 개인 무효 OnPreviewMouseLeftButtonUp (개체를 보낸 사람을 MouseButtonEventArgs 전자) { 부울 : – Akanksha
은 'EnableClickHold'내가 다음 편집을해야 발견 같은 버튼 –