$trigger1=New-Object Windows.Eventtrigger([Windows.Controls.Textbox]::MouseEnterEvent);
$trigger1.Actions.Add((New-Object windows.Media.Animation.BeginStoryBoard));
$bsbitem=$trigger1.Actions.Item(0);
$bsbitem.StoryBoard=New-Object windows.Media.Animation.StoryBoard;
$bsbitem.StoryBoard.Children.Add((New-Object windows.media.animation.coloranimation([Windows.Media.Colors]::LightBlue,[Timespan]::FromSeconds(1))));
[Windows.Media.Animation.StoryBoard]::SetTargetProperty($bsbitem.StoryBoard.Children.Item(0),[Windows.PropertyPath] "Background.Color");
$styletxtbox.Triggers.Add($trigger1);
Several things should be noted:
- You create the EventTrigger using the associated event from the type you are animating.
- $styletxtbox is a Windows.Style object.
- The trigger events mouse be events derived from Windows.TriggerAction. This means they must be either wrappers for a Storyboard, or a SoundPlayerAction. You can use Keyframes to quickly change a color, or use the smooth transitions defined in the inheritance hierarchy for Windows.Media.Animation.Animationtimeline
- Set the property operated on via [Windows.Media.Animation.StoryBoard]::SetTargetProperty.
- The wastefulness of dynamically generating XAML code for a dynamic form, parsing it and creating the objects VS just creating or manipulating the objects involved directly.
- The capacity to easily reference every one of the elements of the form as a variable, for instance in writing event handlers.
No comments:
Post a Comment