You are developing an application by using Silverlight 4 and Microsoft .NET Framework 4. You create a new user control in the application. You add the following XAML fragment
to the control:
<StackPanel KeyDown=”App_KeyDown” Orientation=”Vertical”>
<TextBox x:Name=”firstName” />
<TextBox x:Name=”lastName” />
<TextBox x:Name=”address” />
</StackPanel>
You add the following code segment in the code behind file of the control. (Line numbers are included for reference only.)
01 private void App_KeyDown(object sender, KeyEventArgs e)
02 {
03
04 }
05
06 private void FirstAndLastNameKeyDown()
07 {
08 …
09 }
You need to ensure that the First And LastName KeyDown method is invoked when a key is pressed while the focus is on the firstName or lastName TextBox controls. You also need to ensure that the default behavior of the controls remains unchanged.
Which code segment should you add at line 03?
A.
if (((FrameworkElement)sender).Name == “firstName” ||
((FrameworkElement)sender).Name == “lastName”)
{
FirstAndLastNameKeyDown();
}
e.Handled = false;
B.
if (((FrameworkElement)sender).Name == “firstName” ||
((FrameworkElement)sender).Name == “lastName”)
{
FirstAndLastNameKeyDown();
}
e.Handled = true;
C.
if (((FrameworkElement)e.OriginalSource).Name == “firstName” ||
((FrameworkElement)e.OriginalSource).Name == “lastName”)
{
FirstAndLastNameKeyDown();
}
e.Handled = false;
D.
if (((FrameworkElement)e.OriginalSource).Name == “firstName” ||
((FrameworkElement)e.OriginalSource).Name == “lastName”)
{
FirstAndLastNameKeyDown();
}
e.Handled = true;