Which code fragment should you insert at line 07?

You use Microsoft .NET Framework 4 to create a Windows Presentation Foundation (WPF) application.
You add a TreeView control to show the hierarchical structure of orders and order details.
Each order contains an ObservableCollection named OrderDetails.
You write the following code fragment. (Line numbers are included for reference only.)
01<Grid>
02<Grid.Resources>
03<src:Orders x:Key=”orders”/>
04<DataTemplate x:Key=”OrderDetailTemplate”>
05<TextBlock Text=”{Binding Path=.}” />
06</DataTemplate>
07
08</Grid.Resources>
09<TreeView DataContext=”{StaticResource orders}”
10ItemsSource=”{Binding Path=.}”
11ItemTemplate=”{StaticResource OrderTemplate}”/>
12 </Grid>
You need to ensure that the TreeView control meets the following requirements:
* Each order is shown as a TreeView node.
* The order nodes have order detail nodes as children.
* The order detail nodes have no children.
Which code fragment should you insert at line 07?

You use Microsoft .NET Framework 4 to create a Windows Presentation Foundation (WPF) application.
You add a TreeView control to show the hierarchical structure of orders and order details.
Each order contains an ObservableCollection named OrderDetails.
You write the following code fragment. (Line numbers are included for reference only.)
01<Grid>
02<Grid.Resources>
03<src:Orders x:Key=”orders”/>
04<DataTemplate x:Key=”OrderDetailTemplate”>
05<TextBlock Text=”{Binding Path=.}” />
06</DataTemplate>
07
08</Grid.Resources>
09<TreeView DataContext=”{StaticResource orders}”
10ItemsSource=”{Binding Path=.}”
11ItemTemplate=”{StaticResource OrderTemplate}”/>
12 </Grid>
You need to ensure that the TreeView control meets the following requirements:
* Each order is shown as a TreeView node.
* The order nodes have order detail nodes as children.
* The order detail nodes have no children.
Which code fragment should you insert at line 07?

A.
<HierarchicalDataTemplate x:Key=”OrderTemplate” DataType=”Order” ItemTemplate=”{StaticResource OrderDetailTemplate}”>
<TextBlock Text=”{Binding Path=.}” />
</HierarchicalDataTemplate>

B.
<HierarchicalDataTemplate x:Key=”OrderTemplate” ItemsSource=”{Binding Path=OrderDetails}” ItemTemplate=”{StaticResource OrderDetailTemplate}”>
<TextBlock Text=”{Binding Path=.}” />
</HierarchicalDataTemplate>

C.
<HierarchicalDataTemplate x:Key=”OrderTemplate” ItemsSource=”{Binding Path=Orders}” ItemTemplate=”{StaticResource OrderDetailTemplate}”>
<TextBlock Text=”{Binding Path=.}” />
</HierarchicalDataTemplate>

D.
<HierarchicalDataTemplate x:Key=”OrderTemplate” ItemsSource=”{Binding Path=Orders}” DataType=”Order”>
<TextBlock Text=”{Binding Path=.}” />



Leave a Reply 0

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