여기 당신이 사용할 수있는 유사하지만 간단한 클래스입니다 :이
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Windows.Interactivity;
using System.Windows.Threading;
namespace SilverlightApplication14
{
public class LongClickButton : Button
{
public event EventHandler LongClick;
public static DependencyProperty HowLongProperty = DependencyProperty.Register("HowLong", typeof(double), typeof(LongClickButton), new PropertyMetadata(3000.0));
public double HowLong
{
get
{
return (double)this.GetValue(HowLongProperty);
}
set
{
this.SetValue(HowLongProperty, value);
}
}
private DispatcherTimer timer;
public LongClickButton()
{
this.timer = new DispatcherTimer();
this.timer.Tick += new EventHandler(timer_Tick);
}
private void timer_Tick(object sender, EventArgs e)
{
this.timer.Stop();
// Timer elapsed while button was down, fire long click event.
if (this.LongClick != null)
{
this.LongClick(this, EventArgs.Empty);
}
}
protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
{
base.OnMouseLeftButtonDown(e);
this.timer.Interval = TimeSpan.FromMilliseconds(this.HowLong);
this.timer.Start();
}
protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e)
{
base.OnMouseLeftButtonUp(e);
this.timer.Stop();
}
}
}
새 LongClick 이벤트와 함께 혼합의 표준 행동 중 하나를 사용할 수 있습니다. ... 내가 구현하기 위해 노력했습니다 응답에 대한
<local:LongClickButton Margin="296,170,78,91">
<i:Interaction.Triggers>
<i:EventTrigger EventName="LongClick">
<ei:ChangePropertyAction PropertyName="Background" TargetName="LayoutRoot">
<ei:ChangePropertyAction.Value>
<SolidColorBrush Color="#FFFF1C1C"/>
</ei:ChangePropertyAction.Value>
</ei:ChangePropertyAction>
</i:EventTrigger>
</i:Interaction.Triggers>
</local:LongClickButton>
많은 감사 : 탐색을 트리거 LongClick로 설정된 eventtrigger를 사용하고 원하는 MS (기본값은 3000)의 수에 HowLong 속성을 설정하고 그것 ... 내가 할 수있을 때 나는 그것을 점검 할 것이다. 그렇지 않으면 나는 내가 불평 할 수 없다 : D –
사건이 화면에서 (내 경우에는 위치에서) 수정할 것이었지만 완벽하게 일했다. .....정말 고맙습니다 –