PrepAway - Latest Free Exam Questions & Answers

Which code fragment should you use?

You use Microsoft .NET Framework 4 to create a Windows Presentation Foundation (WPF) application. The application contains an ObservableCollection object named Pictures that contains several Picture objects. Each Picture object contains the Name and PictureFilePath properties. You add a ListBox control to the application. You need to ensure that the pictures are displayed in the ListBox control. Which code fragment should you use?

PrepAway - Latest Free Exam Questions & Answers

A.
<ListBox ItemsSource=”{Binding Source={StaticResource pictures}}”> <ListBox.ItemTemplate> <DataTemplate> <TextBlock><TextBlock.Text> <Binding Path=”PictureFilePath” /> </TextBlock.Text></TextBlock> </DataTemplate> </ListBox.ItemTemplate> </ListBox>

B.
<ListBox ItemsSource=”{Binding Source={StaticResource pictures}}”> <ListBox.ItemTemplate> <DataTemplate> <Image Source=”{Binding Source={StaticResource pictures}, Path=PictureFilePath}”/> </DataTemplate> </ListBox.ItemTemplate> </ListBox>

C.
<ListBox ItemsSource=”{Binding Source={StaticResource pictures}}”> <ListBox.ItemTemplate> <DataTemplate> <TextBlock><TextBlock.Text> <Binding Path=”Name” /> </TextBlock.Text></TextBlock> </DataTemplate> </ListBox.ItemTemplate></ListBox>

D.
<ListBox ItemsSource=”{Binding Source={StaticResource pictures}}”> <ListBox.ItemTemplate> <DataTemplate> <Image Source=”{Binding Path=PictureFilePath}”/> </DataTemplate> </ListBox.ItemTemplate> </ListBox>


Leave a Reply