Which code segment should you insert at line 09?

You are creating a Windows Presentation Foundation application by using Microsoft .NET Framework 3.5.
The application contains a CheckBox control named checkBox1 and a TextBox control named t1. The application contains the following code segment.

public class CheckBoxToColorConverter : System.Windows.Data.IValueConverter
{
public object Convert(object valueIn, System.Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
bool isChecked = Convert.ToBoolean(valueIn) ;
switch (isChecked)
{
case true:
return "Green";

default:
break;
}

return "Red";
}
}

You write the following code fragment.

01 <Window.Resources>
02 <src:CheckBoxToColorConverterKey="checkBoxToColorConverter"/>
03 <Style x:Key="CheckBoxChecked">
04 <Setter Property="Control.Template" Value="checkBoxToColorConverter" >
05 </Setter>
06 </Style>
07 </Window.Resources>
08 <StackPanel>
09
10 <CheckBox Name="checkBox1">Check For Green</CheckBox>
11 </StackPanel>

You need to ensure that when checkBox1 is in the selected state, the background of t1 changes to red.
Which code segment should you insert at line 09?

You are creating a Windows Presentation Foundation application by using Microsoft .NET Framework 3.5.
The application contains a CheckBox control named checkBox1 and a TextBox control named t1. The application contains the following code segment.

public class CheckBoxToColorConverter : System.Windows.Data.IValueConverter
{
public object Convert(object valueIn, System.Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
bool isChecked = Convert.ToBoolean(valueIn) ;
switch (isChecked)
{
case true:
return "Green";

default:
break;
}

return "Red";
}
}

You write the following code fragment.

01 <Window.Resources>
02 <src:CheckBoxToColorConverterKey="checkBoxToColorConverter"/>
03 <Style x:Key="CheckBoxChecked">
04 <Setter Property="Control.Template" Value="checkBoxToColorConverter" >
05 </Setter>
06 </Style>
07 </Window.Resources>
08 <StackPanel>
09
10 <CheckBox Name="checkBox1">Check For Green</CheckBox>
11 </StackPanel>

You need to ensure that when checkBox1 is in the selected state, the background of t1 changes to red.
Which code segment should you insert at line 09?

A.
<TextBox Text="TextBox"x:Name="t1" Background="{Binding Path=IsChecked, ElementName=TextBox, Mode=Default, Converter={StaticResource checkBoxToColorConverter}}"/>

B.
<TextBox Text="TextBox"x:Name="t1" Background="{Binding Path=IsChecked, ElementName=checkBox1, Mode=Default, Converter={StaticResource checkBoxToColorConverter}}"/>

C.
<StackPanel>
<TextBox Text="TextBox" x:Name="t1" Background="{Binding ElementName=checkBox1}"/>
<CheckBox Name="checkBox1">Check For Green</CheckBox>
</StackPanel>

D.
<TextBox Text="TextBox" x:Name="t1" Background="{Binding Path=IsChecked, ElementName=checkBox1, Mode=Default, Converter={StaticResource CheckBoxChecked}}"/>



Leave a Reply 0

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