What should you do to ensure that the animation terminates when a user clicks the rectangle?

You are creating a Windows Presentation Foundation application by using Microsoft .NET Framework 3.5.
You create a window by using the following XAML code fragment.
(Line numbers are included for reference only.)

01 <Rectangle x:Name="rect">
02 <Rectangle.Fill>
03 <SolidColorBrush x:Name="brush"/>
04 </Rectangle.Fill>
05 <Rectangle.Triggers>
06 <EventTrigger RoutedEvent="Rectangle.Loaded">
07 <BeginStoryboard x:Name="beginName">
08 <Storyboard x:Name="boardName">
09
10 </Storyboard>
11 </BeginStoryboard>
12 </EventTrigger>
13 <EventTrigger RoutedEvent="Rectangle.MouseLeftButtonDown">
14
15 </EventTrigger>
16 </Rectangle.Triggers>
17 </Rectangle>

You need to ensure that the animation starts when the rectangle is loaded. You also need to ensure that the animation terminates when a user clicks the rectangle.
What should you do?

You are creating a Windows Presentation Foundation application by using Microsoft .NET Framework 3.5.
You create a window by using the following XAML code fragment.
(Line numbers are included for reference only.)

01 <Rectangle x:Name=”rect”>
02 <Rectangle.Fill>
03 <SolidColorBrush x:Name=”brush”/>
04 </Rectangle.Fill>
05 <Rectangle.Triggers>
06 <EventTrigger RoutedEvent=”Rectangle.Loaded”>
07 <BeginStoryboard x:Name=”beginName”>
08 <Storyboard x:Name=”boardName”>
09
10 </Storyboard>
11 </BeginStoryboard>
12 </EventTrigger>
13 <EventTrigger RoutedEvent=”Rectangle.MouseLeftButtonDown”>
14
15 </EventTrigger>
16 </Rectangle.Triggers>
17 </Rectangle>

You need to ensure that the animation starts when the rectangle is loaded. You also need to ensure that the animation terminates when a user clicks the rectangle.
What should you do?

A.
Insert the following XAML code fragment at line 09.
<ColorAnimation Storyboard.TargetName=”brush” Storyboard.TargetProperty=”Color” From=”Blue” To=”Yellow” RepeatBehavior=”Forever”/>
Insert the following XAML code fragment at line 14.
<StopStoryboard BeginStoryboardName=”boardName”/>

B.
Insert the following XAML code fragment at line 09.
<ColorAnimation Storyboard.TargetName=”brush” Storyboard.TargetProperty=”Color” From=”Blue” To=”Yellow” RepeatBehavior=”Forever”/>
Insert the following XAML code fragment at line 14.
<StopStoryboard BeginStoryboardName=”beginName”/>

C.
Insert the following XAML code fragment at line 09.
<ColorAnimation Storyboard.TargetName=”rect” Storyboard.TargetProperty=”Color” From=”Blue” To=”Yellow” RepeatBehavior=”Forever”/>
Insert the following XAML code fragment at line 14.
<StopStoryboard BeginStoryboardName=”beginName”/>

D.
Insert the following XAML code fragment at line 09.
<ColorAnimation Storyboard.TargetName=”rect” Storyboard.TargetProperty=”Brush.Color” From=”Blue” To=”Yellow” RepeatBehavior=”Forever”/>
Insert the following XAML code fragment at line 14.
<StopStoryboard BeginStoryboardName=”beginName”/>



Leave a Reply 0

Your email address will not be published. Required fields are marked *