Which XAML code fragment should you insert at line 10?

You are creating a Windows Presentation Foundation application by using Microsoft .NET Framework 3.5.
You write the following XAML code fragment.

01 <StackPanel.Resources>
02 <ControlTemplate x:Key="buttonTemplate" TargetType="{x:Type Button}">
03 <Grid>
04 <Rectangle x:Name="buttonBackground" Width="100" Height="30" Fill="Blue" />
05 <WrapPanel>
06 <Image x:Name="buttonImage" Width="20" Height="20" Source="buttonImage.jpg" />
07 <ContentPresenter Margin="10" />
08 </WrapPanel>
09 </Grid>
10
11 </ControlTemplate>
14 </StackPanel.Resources>

You plan to apply the buttonTemplate template to 20 buttons. You need to ensure that a sound file named soundFile.wav is played when the user moves the
mouse pointer over the image on any of the 20 buttons.
Which XAML code fragment should you insert at line 10?

You are creating a Windows Presentation Foundation application by using Microsoft .NET Framework 3.5.
You write the following XAML code fragment.

01 <StackPanel.Resources>
02 <ControlTemplate x:Key="buttonTemplate" TargetType="{x:Type Button}">
03 <Grid>
04 <Rectangle x:Name="buttonBackground" Width="100" Height="30" Fill="Blue" />
05 <WrapPanel>
06 <Image x:Name="buttonImage" Width="20" Height="20" Source="buttonImage.jpg" />
07 <ContentPresenter Margin="10" />
08 </WrapPanel>
09 </Grid>
10
11 </ControlTemplate>
14 </StackPanel.Resources>

You plan to apply the buttonTemplate template to 20 buttons. You need to ensure that a sound file named soundFile.wav is played when the user moves the
mouse pointer over the image on any of the 20 buttons.
Which XAML code fragment should you insert at line 10?

A.
<ControlTemplate.Triggers>
<EventTrigger SourceName="buttonImage" RoutedEvent="MouseEnter">
<EventTrigger.Actions>
<SoundPlayerAction Source="soundFile.wav" />
</EventTrigger.Actions>
</EventTrigger>
</ControlTemplate.Triggers>

B.
<ControlTemplate.Triggers>
<EventTrigger SourceName="buttonImage" RoutedEvent="MouseEnter">
<EventTrigger.EnterActions>
<SoundPlayerAction Source="soundFile.wav" />
</EventTrigger.EnterActions>
</EventTrigger>
</ControlTemplate.Triggers>

C.
<ControlTemplate.Triggers>
<EventTrigger RoutedEvent="MouseEnter">
<EventTrigger.EnterActions>
<SoundPlayerAction Source="soundFile.wav" />
</EventTrigger.EnterActions>
</EventTrigger>
</ControlTemplate.Triggers>

D.
<ControlTemplate.Triggers>
<EventTrigger RoutedEvent="MouseEnter">
<EventTrigger.Actions>
<SoundPlayerAction Source="soundFile.wav" />
</EventTrigger.Actions>
</EventTrigger>
</ControlTemplate.Triggers>



Leave a Reply 0

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