PrepAway - Latest Free Exam Questions & Answers

Which XAML code fragment should you use?

You are creating a Windows Presentation Foundation application by using Microsoft .NET Framework 3.5.
You add a ListBox control to the user interface of the application. The ListBox control is data bound to a collection of items. Each item contains the Name and the Url properties of the System.String type. The Url property contains a path to an image.
You need to modify the definition of the ListBox control to meet the following requirements:
* Each item must be displayed on a separate line.
* Each line must contain text that displays the Name property of the item to the left of the line.
* The image that corresponds to the item must appear to the right of the text.
Which XAML code fragment should you use?

PrepAway - Latest Free Exam Questions & Answers

A.
<ListBox Name="lst">
<ListBox.Template>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Name}" />
<Image Source="{Binding Url}" />
</StackPanel>
</ListBox.Template>
</ListBox>

B.
<ListBox Name="lst">
<ListBox.ItemsPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Name}" />
<Image Source="{Binding Url}" />
</StackPanel>
</ListBox.ItemsPanel>
</ListBox>

C.
<ListBox Name="lst">
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Name}" />
<Image Source="{Binding Url}" />
</StackPanel>
</DataTemplate>
</ListBox>

D.
<ListBox Name="lst">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Name}" />
<Image Source="{Binding Url}" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>


Leave a Reply