Thursday, August 16, 2012

How do I capture the mouse when a Silverlight RepeatButton is depressed?

How do I capture the mouse when a Silverlight RepeatButton is depressed?

I have a RepeatButton on a UserControl that acts as the up button. The control is a number spinner of sorts. When the number value goes from 9 to 10 the up button is released because it moves out from under the mouse. I know I can capture the mouse, but my RepeatButton is not giving me MouseLeftButtonDown events. So how do I capture the mouse over the RepeatButton when it is depressed and release the capture when it is released? And should the RepeatButton give me MouseLeftButtonDown events?

Edits:

It would seem that the template content is stealing the button's MouseLeftButtonDown events. Is there anyway I can circumvent the button's content. If I set HitTestVisible to false, the button itself becomes untouchable. I wish silverlight had OnPreview overrides.

Answers & Comments...

Answer: 1

Have you tried utilising MouseLeftButtonUp instead to check if it can occur when the mouse button is released?

Answer by Christian for How do I capture the mouse when a Silverlight RepeatButton is depressed?

Answer: 2

I just had a similar problem with Windows 8/WinRT and found a workaround - you can bind something to the button's IsPressed property and when it gets set to false - it means the button/touch is up.

Answer by Filip Skakun for How do I capture the mouse when a Silverlight RepeatButton is depressed?




No comments:

Post a Comment

Send us your comment related to the topic mentioned on the blog