Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to stop animation of Image-scaling to reset itself?
    primarykey
    data
    text
    <p>I have created a copy of the Button template and added an Image in there. Then I created a mouseover state for *=> MouseOver to scale the image by 0.1. It works. However despite leaving the mouse over the image, the animation resets itself back to initial state as if there was no mouseover still in place. </p> <p>How can I make it stay there?</p> <p>The second question is regarding the hardcoded path of Source within my Image. How can I inject it from the top into the style rather than having it hardcoded for one specific image? So that its more generic?</p> <p>Many Thanks</p> <pre><code>&lt;Style x:Key="ButtonStyle1" TargetType="Button"&gt; &lt;Setter Property="Background" Value="#FF1F3B53"/&gt; &lt;Setter Property="Foreground" Value="#FF000000"/&gt; &lt;Setter Property="Padding" Value="3"/&gt; &lt;Setter Property="BorderThickness" Value="1"/&gt; &lt;Setter Property="BorderBrush"&gt; &lt;Setter.Value&gt; &lt;LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"&gt; &lt;GradientStop Color="#FFA3AEB9" Offset="0"/&gt; &lt;GradientStop Color="#FF8399A9" Offset="0.375"/&gt; &lt;GradientStop Color="#FF718597" Offset="0.375"/&gt; &lt;GradientStop Color="#FF617584" Offset="1"/&gt; &lt;/LinearGradientBrush&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="Button"&gt; &lt;Grid&gt; &lt;VisualStateManager.VisualStateGroups&gt; &lt;VisualStateGroup x:Name="CommonStates"&gt; &lt;VisualStateGroup.Transitions&gt; &lt;VisualTransition GeneratedDuration="0" To="MouseOver"&gt; &lt;Storyboard&gt; &lt;DoubleAnimation Duration="0:0:0.4" To="1.1" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleX)" Storyboard.TargetName="toolbarImage" d:IsOptimized="True"/&gt; &lt;DoubleAnimation Duration="0:0:0.4" To="1.1" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleY)" Storyboard.TargetName="toolbarImage" d:IsOptimized="True"/&gt; &lt;/Storyboard&gt; &lt;/VisualTransition&gt; &lt;/VisualStateGroup.Transitions&gt; &lt;VisualState x:Name="Normal"/&gt; &lt;VisualState x:Name="MouseOver"&gt; &lt;Storyboard&gt; &lt;DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="BackgroundAnimation"/&gt; &lt;ColorAnimation Duration="0" To="#F2FFFFFF" Storyboard.TargetProperty="(Rectangle.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Color)" Storyboard.TargetName="BackgroundGradient"/&gt; &lt;ColorAnimation Duration="0" To="#CCFFFFFF" Storyboard.TargetProperty="(Rectangle.Fill).(GradientBrush.GradientStops)[2].(GradientStop.Color)" Storyboard.TargetName="BackgroundGradient"/&gt; &lt;ColorAnimation Duration="0" To="#7FFFFFFF" Storyboard.TargetProperty="(Rectangle.Fill).(GradientBrush.GradientStops)[3].(GradientStop.Color)" Storyboard.TargetName="BackgroundGradient"/&gt; &lt;/Storyboard&gt; &lt;/VisualState&gt; &lt;VisualState x:Name="Pressed"&gt; &lt;Storyboard&gt; &lt;ColorAnimation Duration="0" To="#FF6DBDD1" Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)" Storyboard.TargetName="Background"/&gt; &lt;DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="BackgroundAnimation"/&gt; &lt;ColorAnimation Duration="0" To="#D8FFFFFF" Storyboard.TargetProperty="(Rectangle.Fill).(GradientBrush.GradientStops)[0].(GradientStop.Color)" Storyboard.TargetName="BackgroundGradient"/&gt; &lt;ColorAnimation Duration="0" To="#C6FFFFFF" Storyboard.TargetProperty="(Rectangle.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Color)" Storyboard.TargetName="BackgroundGradient"/&gt; &lt;ColorAnimation Duration="0" To="#8CFFFFFF" Storyboard.TargetProperty="(Rectangle.Fill).(GradientBrush.GradientStops)[2].(GradientStop.Color)" Storyboard.TargetName="BackgroundGradient"/&gt; &lt;ColorAnimation Duration="0" To="#3FFFFFFF" Storyboard.TargetProperty="(Rectangle.Fill).(GradientBrush.GradientStops)[3].(GradientStop.Color)" Storyboard.TargetName="BackgroundGradient"/&gt; &lt;/Storyboard&gt; &lt;/VisualState&gt; &lt;VisualState x:Name="Disabled"&gt; &lt;Storyboard&gt; &lt;DoubleAnimation Duration="0" To=".55" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="DisabledVisualElement"/&gt; &lt;/Storyboard&gt; &lt;/VisualState&gt; &lt;/VisualStateGroup&gt; &lt;VisualStateGroup x:Name="FocusStates"&gt; &lt;VisualState x:Name="Focused"&gt; &lt;Storyboard&gt; &lt;DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="FocusVisualElement"/&gt; &lt;/Storyboard&gt; &lt;/VisualState&gt; &lt;VisualState x:Name="Unfocused"/&gt; &lt;/VisualStateGroup&gt; &lt;/VisualStateManager.VisualStateGroups&gt; &lt;VisualStateManager.CustomVisualStateManager&gt; &lt;ei:ExtendedVisualStateManager/&gt; &lt;/VisualStateManager.CustomVisualStateManager&gt; &lt;Border x:Name="Background" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="White" CornerRadius="3"&gt; &lt;Grid Background="{TemplateBinding Background}" Margin="1"&gt; &lt;Border x:Name="BackgroundAnimation" Background="#FF448DCA" Opacity="0"/&gt; &lt;Rectangle x:Name="BackgroundGradient"&gt; &lt;Rectangle.Fill&gt; &lt;LinearGradientBrush EndPoint=".7,1" StartPoint=".7,0"&gt; &lt;GradientStop Color="#FFFFFFFF" Offset="0"/&gt; &lt;GradientStop Color="#F9FFFFFF" Offset="0.375"/&gt; &lt;GradientStop Color="#E5FFFFFF" Offset="0.625"/&gt; &lt;GradientStop Color="#C6FFFFFF" Offset="1"/&gt; &lt;/LinearGradientBrush&gt; &lt;/Rectangle.Fill&gt; &lt;/Rectangle&gt; &lt;/Grid&gt; &lt;/Border&gt; &lt;Image x:Name="toolbarImage" Source="./Images/New.png"&gt; &lt;Image.RenderTransform&gt; &lt;CompositeTransform CenterY="24" CenterX="24"/&gt; &lt;/Image.RenderTransform&gt; &lt;/Image&gt; &lt;ContentPresenter x:Name="contentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/&gt; &lt;Rectangle x:Name="DisabledVisualElement" Fill="#FFFFFFFF" IsHitTestVisible="false" Opacity="0" RadiusY="3" RadiusX="3"/&gt; &lt;Rectangle x:Name="FocusVisualElement" IsHitTestVisible="false" Margin="1" Opacity="0" RadiusY="2" RadiusX="2" Stroke="#FF6DBDD1" StrokeThickness="1"/&gt; &lt;/Grid&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; </code></pre> <p><strong>UPDATE:</strong></p> <p>Despite having set the autoreverse to false, I still havent sorted out the first issue.</p> <pre><code>&lt;VisualTransition From="Normal" GeneratedDuration="0" To="MouseOver"&gt; &lt;Storyboard&gt; &lt;DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="BackgroundAnimation"/&gt; &lt;ColorAnimation Duration="0" To="#F2FFFFFF" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Color)" Storyboard.TargetName="BackgroundGradient"/&gt; &lt;ColorAnimation Duration="0" To="#CCFFFFFF" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[2].(GradientStop.Color)" Storyboard.TargetName="BackgroundGradient"/&gt; &lt;ColorAnimation Duration="0" To="#7FFFFFFF" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[3].(GradientStop.Color)" Storyboard.TargetName="BackgroundGradient"/&gt; &lt;DoubleAnimation Duration="0:0:0.4" To="1.1" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleX)" Storyboard.TargetName="toolbarImage" AutoReverse="False"/&gt; &lt;DoubleAnimation Duration="0:0:0.4" To="1.1" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleY)" Storyboard.TargetName="toolbarImage" AutoReverse="False"/&gt; &lt;/Storyboard&gt; &lt;/VisualTransition&gt; </code></pre> <p><strong>UPDATE 2:</strong></p> <p>I have uploaded a sample here to demo what I mean. Hover with mouse over the New button: <a href="http://sl.venuscloud.com/" rel="nofollow">http://sl.venuscloud.com/</a></p> <p>Am I missing something obvious? Thanks</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload