2013-10-03 32 views
1

我有MouseLeftButtonUp不費一槍一個問題,當我向下按我的鼠標左鍵一個UIElement(即Rectangle),然後將我的鼠標移動到另一個Rectangle然後鬆開鼠標左鍵。在Win電話處理的MouseLeftButtonUp在不同的UI元素8

根據http://msdn.microsoft.com/en-us/library/system.windows.uielement.mouseleftbuttonup.aspx這個頁面是因爲該事件僅觸發時相同的元素鼠標左鍵在上按下,

發生時,當鼠標指針鼠標左鍵被釋放在這個元素上。

這個問題怎麼解決?

我試圖在兩個矩形下面添加一個Grid元素來處理MouseLeftButtonUp事件,但似乎沒有解決問題。從Rect移動到Rect時,它不會觸發,但從Rect移動到Grid時會觸發。從Grid移動到Rect時,它也不會觸發。不同的冒泡策略?

Here is what I'm working with. Examine the second column where each Rectangle is YELLOW. The have been highlighted by pressing on the top rectangle and dragging down to the bottom Rectangle. Once reaching the bottom rectangle I would like to be able to have the button up event occur (by any means) to perform some action.. doesn't work!

這裏是我的工作。檢查每個矩形爲黃色的第二列。通過按下頂部矩形並向下拖動到底部矩形,它們被「高亮顯示」。一旦到達底部的矩形,我希望能夠發生鼠標按鈕事件(通過任何方式)執行某些操作..不起作用!

如果這看起來像是這種類型的「突出」機制的怪異解決方案,或者在這種情況下對矩形的濫用,請不要害羞,我是WP8的新手。

回答

2

考慮添加Grid所有的矩形,這樣你會得到MouseButtonUp(只要鼠標是在網格上公佈),但你必須計算其矩形用基礎上,MouseEventArgs.GetPosition移動。

你可能也想看看UIElement.CaptureMouse().ReleaseMouseCapture()。捕獲鼠標指MouseButtonUp甚至當鼠標移動從MouseButtonDown以外發射 - Rectangle,但MouseMoveMouseButtonUp將提高爲捕獲矩形(所以你仍然要計算矩形突出),直到它調用ReleaseMouseCapture()