PrepAway - Latest Free Exam Questions & Answers

Which code segment should you insert at line 06?

You are developing a Silverlight 4 application.
The application contains an XAML page that defines the following Grid control.
<Grid Name=”gridBody” >
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<TextBlock Text=”Employee Info” />
<TextBlock Text=”Please enter employee info” Grid.Row=”1″ Height=”20″ VerticalAlignment=”Top” />
<TextBox x:Name=”EmpInfo” Grid.Row=”1″ Margin=”0,25,0,0″ TextWrapping=”Wrap” /></Grid>

The codebehind file for myPage.xaml contains the following code segment. (Line numbers are included for reference only.)

01 public myPage()
02 {
03 InitializeComponent();
04
05 UserControl control = new MyCustomControl();
06
07 }
You need to replace the contents of the second row of gridBody with a user control of the MyCustomControl type. Which code segment should you insert at line 06?

PrepAway - Latest Free Exam Questions & Answers

A.
gridBody.Children.Insert(1, control);

B.
gridBody.RowDefinitions.Remove(gridBody.RowDefinitions[1]);
gridBody.Children.Insert(1, control);

C.
gridBody.Children.Clear();
Grid.SetRow(control, 1);
gridBody.Children.Add(control);

D.
List<UIElement> remove = gridBody.Children.Where(c => c is FrameworkElement && Grid.GetRow((FrameworkElement)c) == 1).ToList(); foreach (UIElement element in remove)
{
gridBody.Children.Remove(element);
}
Grid.SetRow(control, 1);
gridBody.Children.Add(control);


Leave a Reply