Which XAML fragment should you use?

You are developing a Silverlight 4 application. The application contains an OrderItem class that has a public interface property named Quantity and a public Decimal property named UnitPrice. The application also contains an ExtendedPriceConverter class that calculates the total price for the OrderItem. The application requires a UnitPrice in the value of the converter and a Quantity as the parameter. You create an XAML page that contains a TextBlock control. The converter is defined in the page that contains the following XAML fragment. (Line numbers are included for reference only.)

01 <UserControl.Resources>
02 <converters: ExtendedPriceConverter x:Key=”epc”></converters: ExtendedPriceConverter>
03 </UserControl.Resources>
You need to ensure that the TextBlock control uses ExtendedPriceConverter to display the extended price when bound to an OrderItem. Which XAML fragment should you use?

You are developing a Silverlight 4 application. The application contains an OrderItem class that has a public interface property named Quantity and a public Decimal property named UnitPrice. The application also contains an ExtendedPriceConverter class that calculates the total price for the OrderItem. The application requires a UnitPrice in the value of the converter and a Quantity as the parameter. You create an XAML page that contains a TextBlock control. The converter is defined in the page that contains the following XAML fragment. (Line numbers are included for reference only.)

01 <UserControl.Resources>
02 <converters: ExtendedPriceConverter x:Key=”epc”></converters: ExtendedPriceConverter>
03 </UserControl.Resources>
You need to ensure that the TextBlock control uses ExtendedPriceConverter to display the extended price when bound to an OrderItem. Which XAML fragment should you use?

A.
<TextBlock Text=”{Binding Path=UnitPrice, Converter={StaticResource epc}, ConverterParameter='{Binding Quantity}’}” />

B.
<TextBlock Text=”{Binding Path=UnitPrice, Converter={StaticResource epc}, ConverterParameter=Quantity}” />

C.
<TextBlock Text=”{Binding Path=UnitPrice, ConverterParameter='{Binding Quantity}’}” />

D.
<TextBlock Text=”{Binding Path=UnitPrice, Converter={StaticResource epc}, ConverterParameter=’Binding Quantity’}” />



Leave a Reply 0

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