locked
Animação (simples) RRS feed

  • Pergunta

  • Olá, galera.

    Criei um storyboard no bend, só que quando abro o programa ela já anima. Eu quero anima-la assim que eu clicar no button.

    Alguém sabe me ajudar?

    <Window
    	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    	xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" xmlns:im="clr-namespace:Microsoft.Expression.Interactivity.Media;assembly=Microsoft.Expression.Interactions"
    	x:Class="StyleAMC.MainWindow"
    	x:Name="Window"
    	Title="MainWindow"
    	Width="709" Height="467.333" Loaded="Window_Loaded">
    	<Window.Resources>
    		<Storyboard x:Key="storymenu" AutoReverse="False" RepeatBehavior="1x" SlipBehavior="Grow" Duration="Automatic" FillBehavior="HoldEnd">
    			<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="canvas">
    				<SplineDoubleKeyFrame KeyTime="0" Value="217"/>
    				<SplineDoubleKeyFrame KeyTime="0:0:0.9" Value="0"/>
    			</DoubleAnimationUsingKeyFrames>
    			<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)" Storyboard.TargetName="canvas">
    				<SplineDoubleKeyFrame KeyTime="0" Value="2"/>
    				<SplineDoubleKeyFrame KeyTime="0:0:0.9" Value="0"/>
    			</DoubleAnimationUsingKeyFrames>
    			<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="canvas">
    				<DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}"/>
    			</ObjectAnimationUsingKeyFrames>
    			<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)" Storyboard.TargetName="canvas">
    				<SplineDoubleKeyFrame KeyTime="0" Value="1"/>
    				<SplineDoubleKeyFrame KeyTime="0:0:0.9" Value="1.008"/>
    			</DoubleAnimationUsingKeyFrames>
    		</Storyboard>
    	</Window.Resources>
    	<Window.Triggers>
    		<EventTrigger RoutedEvent="FrameworkElement.Loaded">
    			<BeginStoryboard Storyboard="{StaticResource storymenu}"/>
    		</EventTrigger>
    	</Window.Triggers>
    
    	<Grid x:Name="LayoutRoot">
    		<Canvas x:Name="panelbackground" Background="#FF0C6D37" Margin="0,0,0,-0.667"/>
    		<Canvas x:Name="canvas" HorizontalAlignment="Right" Width="211.002" Background="#FF0C8744" RenderTransformOrigin="0.5,0.5" Margin="0,0,-0.046,-0.667">
    			<Canvas.RenderTransform>
    				<TransformGroup>
    					<ScaleTransform/>
    					<SkewTransform/>
    					<RotateTransform/>
    					<TranslateTransform/>
    				</TransformGroup>
    			</Canvas.RenderTransform>
    			<Image Height="59.333" Width="211.002" Source="menu.png" Stretch="Fill"/>
    			<Image Height="43.334" Canvas.Top="59.333" Width="211.002" Source="compraevenda.png" Stretch="Fill"/>
    			<Image Height="43.334" Width="211.002" Canvas.Top="126.667" Source="cadastro.png" Stretch="Fill"/>
    			<Image Height="43.334" Width="211.002" Canvas.Top="194.001" Source="estoque.png" Stretch="Fill"/>
    			<Image Height="43.334" Width="211.002" Canvas.Top="261.335" Source="relatorio.png" Stretch="Fill"/>
    			<Image Height="43.334" Width="211.002" Canvas.Top="328.669" Source="config.png" Stretch="Fill"/>
    		</Canvas>
    		<Canvas x:Name="panelconteudo" Margin="0,0,210.956,-0.667">
    			<Canvas x:Name="panellogin" Height="215" Width="362" Canvas.Left="58" Canvas.Top="103">
    				<Label Content="login:" Width="75.043" FontSize="21.333" Foreground="White"/>
    				<Label Content="senha:" Width="75.043" FontSize="21.333" Foreground="White" Canvas.Top="62.373"/>
    				<TextBox TextWrapping="Wrap" Canvas.Left="79.043" Canvas.Top="8" Width="245.553" Height="26.03"/>
    				<TextBox TextWrapping="Wrap" Canvas.Left="79.043" Canvas.Top="68.716" Width="245.553" Height="26.03"/>
                    <Button Canvas.Left="250" Canvas.Top="112" Height="23" Name="btn_ok" Width="75" Click="btn_ok_Click">
                        <Button.Background>
                            <ImageBrush ImageSource="/StyleAMC;component/cadastro.png" />
                        </Button.Background>
                    </Button>
                </Canvas>
    		</Canvas>
    	</Grid>
    </Window>

    segunda-feira, 22 de outubro de 2012 02:54

Todas as Respostas

  • Pelo que vi em seu código, você adicionou o trigger da animação na janela, fazendo com que a animação carregue quando a janela for carregada.

    Remova, o EventTrigger do Windows e adicione um ControlStoryboardAction no seu botão. Segue um exemplo criado rapidamente com o Blend:

    <Button x:Name="button" Content="Button" HorizontalAlignment="Left" VerticalAlignment="Top" Width="75" Margin="233,211,0,0" RenderTransformOrigin="0.5,0.5">
    	<Button.RenderTransform>
    		<CompositeTransform/>
    	</Button.RenderTransform>
    	<i:Interaction.Triggers>
    		<i:EventTrigger EventName="Click">
    			<ei:ControlStoryboardAction Storyboard="{StaticResource Storyboard1}"/>
    		</i:EventTrigger>
    	</i:Interaction.Triggers>
    </Button>

    domingo, 4 de novembro de 2012 12:31