Click here to Skip to main content
15,881,882 members
Home / Discussions / WPF
   

WPF

 
AnswerRe: WPF event binding Pin
Ian Shlasko19-Mar-09 3:47
Ian Shlasko19-Mar-09 3:47 
QuestionHow to set the image inside a datagrid Pin
salon17-Mar-09 20:45
salon17-Mar-09 20:45 
AnswerRe: How to set the image inside a datagrid Pin
Mark Salsbery18-Mar-09 6:15
Mark Salsbery18-Mar-09 6:15 
Questionsilverlight Pin
Ch.Gayatri Subudhi17-Mar-09 20:08
Ch.Gayatri Subudhi17-Mar-09 20:08 
AnswerRe: silverlight Pin
Mark Salsbery18-Mar-09 6:22
Mark Salsbery18-Mar-09 6:22 
GeneralRe: silverlight Pin
Ch.Gayatri Subudhi19-Mar-09 19:03
Ch.Gayatri Subudhi19-Mar-09 19:03 
QuestionTrigger Blend Storyboard from code behind. Pin
emptythetill17-Mar-09 9:52
emptythetill17-Mar-09 9:52 
AnswerRe: Trigger Blend Storyboard from code behind. Pin
Pete O'Hanlon17-Mar-09 10:22
mvePete O'Hanlon17-Mar-09 10:22 
All you need to do is retrieve your animation as a Storyboard. Here's a sample you can try:
<Window
   x:Name="Window"
   x:Class="TriggerApplication.Window1"
   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
   Width="640"
   Height="183"
   Title="Window1">
   <Window.Resources>
      <Storyboard x:Key="OnClick1">
         <DoubleAnimationUsingKeyFrames
            BeginTime="00:00:00"
            Storyboard.TargetName="button1"
            Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)">
            <SplineDoubleKeyFrame
               KeyTime="00:00:01"
               Value="326"/>
         </DoubleAnimationUsingKeyFrames>
         <DoubleAnimationUsingKeyFrames
            BeginTime="00:00:00"
            Storyboard.TargetName="button1"
            Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">
            <SplineDoubleKeyFrame
               KeyTime="00:00:01"
               Value="19"/>
         </DoubleAnimationUsingKeyFrames>
         <ColorAnimationUsingKeyFrames
            BeginTime="00:00:00"
            Storyboard.TargetName="button1"
            Storyboard.TargetProperty="(Panel.Background).(GradientBrush.GradientStops)[3].(GradientStop.Color)">
            <SplineColorKeyFrame
               KeyTime="00:00:01"
               Value="#FFB41212"/>
         </ColorAnimationUsingKeyFrames>
         <ColorAnimationUsingKeyFrames
            BeginTime="00:00:00"
            Storyboard.TargetName="button1"
            Storyboard.TargetProperty="(Panel.Background).(GradientBrush.GradientStops)[0].(GradientStop.Color)">
            <SplineColorKeyFrame
               KeyTime="00:00:01"
               Value="#FFD57C7C"/>
         </ColorAnimationUsingKeyFrames>
      </Storyboard>
   </Window.Resources>
   <Window.Triggers>
      <EventTrigger
         RoutedEvent="ButtonBase.Click"
         SourceName="button">
         <BeginStoryboard Storyboard="{StaticResource OnClick1}"/>
      </EventTrigger>
   </Window.Triggers>
   <Grid x:Name="LayoutRoot">
      <Grid.RowDefinitions>
         <RowDefinition/>
         <RowDefinition/>
      </Grid.RowDefinitions>
      <Button
         x:Name="button"
         HorizontalAlignment="Left"
         VerticalAlignment="Top"
         Content="Button"/>
      <Button
         x:Name="button1"
         Grid.Row="1"
         HorizontalAlignment="Left"
         VerticalAlignment="Top"
         Click="button1_Click"
         Content="Button"
         RenderTransformOrigin="0.5,0.5">
         <Button.RenderTransform>
            <TransformGroup>
               <ScaleTransform
                  ScaleX="1"
                  ScaleY="1"/>
               <SkewTransform AngleX="0" AngleY="0"/>
               <RotateTransform Angle="0"/>
               <TranslateTransform X="0" Y="0"/>
            </TransformGroup>
         </Button.RenderTransform>
      </Button>
   </Grid>
</Window>
Then, all you need to do to retrieve the animation and play it is
Storyboard anim = TryFindResource("OnClick1") as Storyboard;
anim.Begin();
I hope that this helps.

"WPF has many lovers. It's a veritable porn star!" - Josh Smith

As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.


My blog | My articles | MoXAML PowerToys



GeneralRe: Trigger Blend Storyboard from code behind. Pin
emptythetill17-Mar-09 11:13
emptythetill17-Mar-09 11:13 
GeneralRe: Trigger Blend Storyboard from code behind. Pin
Pete O'Hanlon17-Mar-09 11:16
mvePete O'Hanlon17-Mar-09 11:16 
GeneralRe: Trigger Blend Storyboard from code behind. Pin
emptythetill17-Mar-09 11:36
emptythetill17-Mar-09 11:36 
GeneralRe: Trigger Blend Storyboard from code behind. Pin
Pete O'Hanlon17-Mar-09 11:41
mvePete O'Hanlon17-Mar-09 11:41 
QuestionValue Converter Work Around For Data Validation Pin
BlitzPackage17-Mar-09 5:11
BlitzPackage17-Mar-09 5:11 
AnswerRe: Value Converter Work Around For Data Validation Pin
Pete O'Hanlon17-Mar-09 5:52
mvePete O'Hanlon17-Mar-09 5:52 
GeneralRe: Value Converter Work Around For Data Validation Pin
BlitzPackage17-Mar-09 6:36
BlitzPackage17-Mar-09 6:36 
QuestionHow to set the background color of a particluar column in Silverlight? Pin
salon17-Mar-09 3:38
salon17-Mar-09 3:38 
QuestionWooHoo!!! Pin
Jammer17-Mar-09 2:49
Jammer17-Mar-09 2:49 
AnswerRe: WooHoo!!! Pin
Pete O'Hanlon17-Mar-09 3:00
mvePete O'Hanlon17-Mar-09 3:00 
GeneralRe: WooHoo!!! Pin
Jammer17-Mar-09 3:03
Jammer17-Mar-09 3:03 
QuestionSilverlight Pin
Ch.Gayatri Subudhi16-Mar-09 22:35
Ch.Gayatri Subudhi16-Mar-09 22:35 
AnswerRe: Silverlight Pin
Mark Salsbery17-Mar-09 10:13
Mark Salsbery17-Mar-09 10:13 
GeneralSilverlight Pin
Ch.Gayatri Subudhi17-Mar-09 18:10
Ch.Gayatri Subudhi17-Mar-09 18:10 
GeneralRe: Silverlight Pin
Mark Salsbery18-Mar-09 5:50
Mark Salsbery18-Mar-09 5:50 
QuestionWPF Control Name overwrite on initialization Pin
NoviceUser0916-Mar-09 22:19
NoviceUser0916-Mar-09 22:19 
Questioncreate chat room in WPF application Pin
psdeepu16-Mar-09 5:51
psdeepu16-Mar-09 5:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.