[英]Is it possible to make RenderTransform animation not modify the hit area for the mouse?
我的按鈕模板上有一個動畫,當IsMouseOver
為true時可以旋轉按鈕。
動畫旋轉按鈕,因此,如果用戶不將光標放在旋轉的錨點附近,則按鈕可以“逃跑”。
我的目標是,即使鼠標在其原始區域內,該按鈕仍將保持懸停狀態(因此,即使該按鈕遠離光標旋轉,它也將保持懸停狀態,並且即使沒有單擊,也將獲得鼠標單擊)直接在上面)。
我以為使用RenderTransform
而不是LayoutTransform
可以解決我的問題,但是不幸的是它仍然會發生。
我該怎么做?
謝謝!
<Storyboard x:Key="HoverAnimation"> <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)" Storyboard.TargetName="border"> <EasingDoubleKeyFrame KeyTime="0:0:1.6" Value="-10.8"> <EasingDoubleKeyFrame.EasingFunction> <BounceEase EasingMode="EaseOut"/> </EasingDoubleKeyFrame.EasingFunction> </EasingDoubleKeyFrame> </DoubleAnimationUsingKeyFrames> <PointAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransformOrigin)" Storyboard.TargetName="border"> <EasingPointKeyFrame KeyTime="0:0:1.6" Value="0.919,0.3"> <EasingPointKeyFrame.EasingFunction> <BounceEase EasingMode="EaseOut"/> </EasingPointKeyFrame.EasingFunction> </EasingPointKeyFrame> </PointAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[1].(SkewTransform.AngleX)" Storyboard.TargetName="border"> <EasingDoubleKeyFrame KeyTime="0:0:1.6" Value="0"/> </DoubleAnimationUsingKeyFrames> </Storyboard>
在按鈕的模板中,彼此疊加添加兩個項目(使用Grid
):
下面的透明邊框占據整個矩形區域,不對其進行轉換。
上面要應用轉換的實際按鈕內容。
我無法提供經過測試的示例代碼,因為您還沒有提供獨立的示例。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.