Click here to Skip to main content
15,860,861 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hy!

I will be very happy if anyone can tell me how can i make this code to work reverse on the second click. The rectangle resize to small, and i want on the second click that this little rectangle grow back. Thanks in advance.

<Window x:Class="asgsag.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <Rectangle Name="Rect" Width="150" Height="250"
              Fill="Transparent" 
              HorizontalAlignment="Left" Margin="0,22,0,12" Stroke="Black">
            <Rectangle.Triggers>
                <EventTrigger RoutedEvent="Rectangle.MouseLeftButtonDown">
                    <EventTrigger.Actions>
                        <BeginStoryboard>
                            <Storyboard>
                                <DoubleAnimation Storyboard.TargetProperty="Width"
                                   From="150"
                                   To="50"
                                   Duration="0:0:5"/>
                                <DoubleAnimation Storyboard.TargetProperty="Height"
                                   From="250"
                                   To="50"
                                   Duration="0:0:5"
                                   />
                            </Storyboard>
                        </BeginStoryboard>
                    </EventTrigger.Actions>
                </EventTrigger>
            </Rectangle.Triggers>
        </Rectangle>
    </Grid>
</Window>
Posted

1 solution

 
Share this answer
 
Comments
boco10 28-Aug-12 15:41pm    
Thanks, but i've found lots of sample aswell but,i just want the simpliest way to do it in xaml. If not necessery i dont want to write code behind. Problem is i have one event trigger, not like mouse enter and mouse leave which is two.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900