开发者

MouseLeftButtonDownEvent firing two times

i have a grid in xaml which contains an image/textblock/buttons in a row . In order to row respond to single click i added the following code in the cs file.

 this.radFilestoPrint.CellLoaded += new EventHandler<Telerik.Windows.Controls.GridView.CellEventArgs>(filesToPrintGrid_CellLoaded);

 void filesToPrintGrid_CellLoaded(object sender, Telerik.Windows.Controls.GridView.CellEventAr开发者_如何学运维gs e)
        {
            if (e.Cell.Column != radFilestoPrint.Columns[4] && e.Cell.Column != radFilestoPrint.Columns[5])
            {
                e.Cell.AddHandler(GridViewCell.MouseLeftButtonDownEvent, new MouseButtonEventHandler(radFilestoPrint_MouseDoubleClick), true);
            }
        }

Now the problem is that the mousedownevent is firing two times. I checked the origin of the message as below and found that it is from the Image itself. I am setting the e.Handled = true after processing the message even though I noticed that i am recieving the e.Handled as true from the from the first time onwards.

  if (((FrameworkElement)e.Source).GetType() != typeof(System.Windows.Controls.Image))
  {
       return;    
  }

Why is the event firing two times? How should i prevent it?

Please advice.

Regards,

John.


I think maybe you handle your event in worst place and it handle for 2 time and with single Down event it fire two event.

foreach cell loaded not for your specified column
Try handle your event in other place


I believe this is a bug in WPF

http://forums.silverlight.net/forums/p/29101/95353.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜