Double Animation with Storyboard

Aug 17, 2011 at 3:17 PM

Hi Jaykul/Doug/James,

I am trying to convert this XAML to ShowUI code:

<TextBlock
  Name="MyFadingText"
  Margin="20"
  Width="640" Height="100" FontSize="48" FontWeight="Bold" Foreground="Maroon">
  This is fading text

  <!-- Animates the text block's opacity. -->
  <TextBlock.Triggers>
    <EventTrigger RoutedEvent="TextBlock.Loaded">
      <BeginStoryboard>
        <Storyboard>
          <DoubleAnimation
            Storyboard.TargetName="MyFadingText"
            Storyboard.TargetProperty="(TextBlock.Opacity)"
            From="1.0" To="0.0" Duration="0:0:5"
            AutoReverse="True" RepeatBehavior="Forever" />
        </Storyboard>
      </BeginStoryboard>
    </EventTrigger>
  </TextBlock.Triggers>
</TextBlock>

Which is taken from this MSDN page (2nd Example)

Here is my ShowUI code :

New-TextBlock -Name "labelHello" -Text "Hello World" -FontSize 36 -Foreground GREEN -Cursor "Hand" -Triggers {
		New-EventTrigger -RoutedEvent "Textblock.Loaded" {
		New-BeginStoryboard {
			New-Storyboard {
				New-DoubleAnimation -From "1.0" -To "0.0" -Duration "0:0:5" -AutoReverse "True" -RepeatBehavior "Forever"			
			}
		}
	}	
} -Show

But i am not sure how to specify the following values , i am talking about these two lines in the XAML :

Storyboard.TargetName="MyFadingText"

Storyboard.TargetProperty="(TextBlock.Opacity)"

thanks

Thiyagu

Twitter (@thiyagu84)

 

Coordinator
Aug 17, 2011 at 3:21 PM
You need to use Set-DependencyProperty.

I've been wanting to put in the hack for how we handled these in PowerBoots (basically, allow you to do: -Storyboard-TargetName "MyFadingText") but it's a significant change and I prioritized other things).
--
Joel

On Wed, Aug 17, 2011 at 11:17 AM, Thiyagu14 <notifications@codeplex.com> wrote:

From: Thiyagu14

Hi Jaykul/Doug/James,

I am trying to convert this XAML to ShowUI code:

<TextBlock
Name="MyFadingText"
Margin="20"
Width="640" Height="100" FontSize="48" FontWeight="Bold" Foreground="Maroon">
This is fading text

<!-- Animates the text block's opacity. -->
<TextBlock.Triggers>
<EventTrigger RoutedEvent="TextBlock.Loaded">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Storyboard.TargetName="MyFadingText"
Storyboard.TargetProperty="(TextBlock.Opacity)"
From="1.0" To="0.0" Duration="0:0:5"
AutoReverse="True" RepeatBehavior="Forever" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</TextBlock.Triggers>
</TextBlock>

Which is taken from this MSDN page (2nd Example)

Here is my ShowUI code :

New-TextBlock -Name "labelHello" -Text "Hello World" -FontSize 36 -Foreground GREEN -Cursor "Hand" -Triggers {
		New-EventTrigger -RoutedEvent "Textblock.Loaded" {
		New-BeginStoryboard {
			New-Storyboard {
				New-DoubleAnimation -From "1.0" -To "0.0" -Duration "0:0:5" -AutoReverse "True" -RepeatBehavior "Forever"			
			}
		}
	}	
} -Show

But i am not sure how to specify the following values , i am talking about these two lines in the XAML :

Storyboard.TargetName="MyFadingText"

Storyboard.TargetProperty="(TextBlock.Opacity)"

thanks

Thiyagu

Twitter (@thiyagu84)

 

Read the full discussion online.

To add a post to this discussion, reply to this email (showui@discussions.codeplex.com)

To start a new discussion for this project, email showui@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com




--
Joel "Jaykul" Bennett
http://HuddledMasses.org
http://PowerShellGroup.org
Aug 17, 2011 at 3:32 PM

thanks for the quick reply, but i still dont get it, do you mean something like this:

New-TextBlock -Name "labelHello" -Text "Hello World" -FontSize 36 -Foreground GREEN -Cursor "Hand" -Triggers {
		New-EventTrigger -RoutedEvent "Textblock.Loaded" {
		New-BeginStoryboard {
			New-Storyboard {
				Set-DependencyProperty -Property "(TextBlock.Opacity)" -Target "labelHello"
				New-DoubleAnimation -From "1.0" -To "0.0" -Duration "0:0:5" -AutoReverse "True" -RepeatBehavior "Forever" {				
				} 
			}
		}
	}	
} -Show

thanks

Thiyagu

Coordinator
Aug 17, 2011 at 6:07 PM

I gotta apologize ... I just tried to do this, and the bottom line is that we don't have the code in Set-DependencyProperty to make this work in the current release -- it should be in the next release, but we've been having some source-control issues getting that released ;-)

Coordinator
Aug 17, 2011 at 7:32 PM

So, ok ... first of all, if you want to check how you're doing when trying to work FROM xaml examples, you can do this:

New-TextBlock -Name "labelHello" -Text "Hello World" -FontSize 36 -Foreground GREEN -Cursor "Hand" -Triggers {
	New-EventTrigger -RoutedEvent ([System.Windows.Controls.Textblock]::LoadedEvent) -Actions {
		New-BeginStoryboard -StoryBoard {
			New-Storyboard -Children {
				New-DoubleAnimation -From "1.0" -To "0.0" -Duration "0:0:15" -AutoReverse:$True -RepeatBehavior "Forever" -OutVariable sb
				Set-DependencyProperty -Target $sb[0] -Property ([System.Windows.Media.Animation.Storyboard]::TargetNameProperty)  -Value labelHello
				Set-DependencyProperty -Target $sb[0] -Property ([System.Windows.Media.Animation.Storyboard]::TargetPropertyProperty) -Value Opacity
			}
		}
	}
} -OutVariable UI | Out-Xaml

I believe this should duplicate what you're asking for almost exactly ... but for some reason it's crashing when I try to show it with

Show-UI $UI[0]
I'll have to spend some time on that later :)

Coordinator
Aug 17, 2011 at 7:33 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Aug 18, 2011 at 5:33 AM

thanks Jaykul,  i will wait for the August release and then try to run it in that.

cheers

Thiyagu