0
我們有一個自定義的ImageButton,我們在按下按鈕時顯示不同的圖像。無論用戶點擊/觸摸長按鈕,我們都要求讓按鈕保持活動狀態1秒。我發現故事板在用戶釋放點擊或觸摸時停止。有沒有辦法停止故事板並保持它的執行?試圖指定一個稍微超過一秒的持續時間,但沒有幫助。下面是相關的代碼:當VisualState結束時,不要停止故事板
<Grid Name="MainGrid" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}" SnapsToDevicePixels="True" Stylus.IsPressAndHoldEnabled="False" Stylus.IsFlicksEnabled="False">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Pressed">
<Storyboard x:Name="VisualStatePressedStoryboard" Duration="0:0:1.1" >
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="PressedImage" Storyboard.TargetProperty="Visibility">
<DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames BeginTime="0:0:1" Storyboard.TargetName="PressedImage" Storyboard.TargetProperty="Visibility">
<DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Hidden}" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Image Name="DefaultImage" Source="{TemplateBinding DefaultImageSource}" SnapsToDevicePixels="True" Stretch="Fill" >
</Image>
<Image Name="PressedImage" Source="{TemplateBinding PressedImageSource}" Stretch="Fill" SnapsToDevicePixels="True" Visibility="Hidden" />
</Grid>
我也嘗試了很多其他的事情觸發了IsPressed財產,EventTrigger的觸下事件,等等
感謝,
我想這是不可能的......按照MSDN「當控制退出狀態,故事板停止。」 https://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k(http%3A%2F%2Fschemas.microsoft.com%2Fwinfx%2F2006%2Fxaml%2Fpresentation%23VisualState);k (HTTP%3A%2F%2Fschemas.microsoft.com%2Fwinfx%2F2006%2Fxaml%2Fpresentation%23VisualStateGroup); K(vs.xmleditor); K(SolutionItemsProject); K(TargetFrameworkMoniker-.NETFramework,版本%3Dv4.6.1)RD =真 – dan