What should you do?

You are developing a Silverlight 4 application. The application defines the following XAML fragment. (Line numbers are included for reference only.)

01 <ComboBox>
02 <ComboBoxItem Content=”Item 1″ />
03 <ComboBoxItem Content=”Item 2″ />
04 <ComboBoxItem Content=”Item 3″ />
05 </ComboBox> The codebehind
file contains the following code segment. (Line numbers are included for reference only.)
06 void PrintText(object sender, SelectionChangedEventArgs args){
07
08 MessageBox.Show( “You selected ” + cbi.Content.ToString() + “.”);
09 }

You need to ensure that when the user selects an item in a ComboBox control, the content of the item is displayed. What should you do?

You are developing a Silverlight 4 application. The application defines the following XAML fragment. (Line numbers are included for reference only.)

01 <ComboBox>
02 <ComboBoxItem Content=”Item 1″ />
03 <ComboBoxItem Content=”Item 2″ />
04 <ComboBoxItem Content=”Item 3″ />
05 </ComboBox> The codebehind
file contains the following code segment. (Line numbers are included for reference only.)
06 void PrintText(object sender, SelectionChangedEventArgs args){
07
08 MessageBox.Show( “You selected ” + cbi.Content.ToString() + “.”);
09 }

You need to ensure that when the user selects an item in a ComboBox control, the content of the item is displayed. What should you do?

A.
Replace the following XAML fragment at line 01. <ComboBox
SelectionChanged=”PrintText”> Add the following code segment at line 07.
ComboBoxItem cbi = ((sender as ComboBox).SelectedItem as ComboBoxItem);

B.
Replace the following XAML fragment at line 01. <ComboBox
SelectionChanged=”PrintText”> Add the following code segment at line 07.
ComboBoxItem cbi = ((sender as ComboBox).SelectedIndex as ComboBoxItem);

C.
Replace the following XAML fragment at line 01. <ComboBox
DropDownClosed=”PrintText”> Add the following code segment at line 07.
ComboBoxItem cbi = ((sender as ComboBox).SelectedItem as ComboBoxItem);

D.
Replace the following XAML fragment at line 01. <ComboBox
DropDownClosed=”PrintText”> Add the following code segment at line 07.
ComboBoxItem cbi = ((sender as ComboBox).SelectedIndex as ComboBoxItem);



Leave a Reply 0

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