Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
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 28-Aug-12 9:45am
boco10672

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
Comments
boco10 at 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)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 460
1 Peter Leow 260
2 OriginalGriff 245
3 Maciej Los 175
4 John C Rayan 146
0 Sergey Alexandrovich Kryukov 7,203
1 OriginalGriff 5,587
2 Peter Leow 4,097
3 Mika Wendelius 2,850
4 CHill60 2,818


Advertise | Privacy | Mobile
Web02 | 2.8.150224.1 | Last Updated 28 Aug 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100