Which code segments should you insert at lines 03 and 05?

You are creating Windows Presentation Foundation application by using Microsoft .NET Framework 3.5.
The application has a TreeView class that builds the directory tree for a given directory. You write the following class that represents a directory.

class Folder
{
public readonly string Name
{
get { … ;}
}

public readonly List<Folder> Subfolders
{
get { … ;}
}
}

You write the following code segment.
(Line numbers are included for reference only.)
01 TreeView tree = new TreeView() ;
02 Folder folder = new Folder("C:");
03
04 FrameworkElementFactory labelFactory = new FrameworkElementFactory(typeof(TextBlock)) ;
05
06 template.VisualTree = labelFactory ;
07 tree.ItemTemplate = template;
08 tree.ItemsSource = folder.Subfolders;

You need to ensure that the TreeView class displays nodes that correspond to the child folders of the C: drive.
Which code segments should you insert at lines 03 and 05?

You are creating Windows Presentation Foundation application by using Microsoft .NET Framework 3.5.
The application has a TreeView class that builds the directory tree for a given directory. You write the following class that represents a directory.

class Folder
{
public readonly string Name
{
get { … ;}
}

public readonly List<Folder> Subfolders
{
get { … ;}
}
}

You write the following code segment.
(Line numbers are included for reference only.)
01 TreeView tree = new TreeView() ;
02 Folder folder = new Folder("C:");
03
04 FrameworkElementFactory labelFactory = new FrameworkElementFactory(typeof(TextBlock)) ;
05
06 template.VisualTree = labelFactory ;
07 tree.ItemTemplate = template;
08 tree.ItemsSource = folder.Subfolders;

You need to ensure that the TreeView class displays nodes that correspond to the child folders of the C: drive.
Which code segments should you insert at lines 03 and 05?

A.
1. Insert the following code segment at line 03.
HierarchicalDataTemplate template = new HierarchicalDataTemplate(folder);
template.ItemsSource = new Binding("Subfolders") ;
2. Insert the following code segment at line 05.
labelFactory.SetBinding(TextBlock.TextProperty, new Binding("Name")) ;

B.
1. Insert the following code segment at line 03.
HierarchicalDataTemplate template = new HierarchicalDataTemplate(typeof(Folder));
template.ItemsSource = new Binding("Subfolders");
2. Insert the following code segment at line 05.
labelFactory.SetBinding(TextBlock.TextProperty, new Binding("Name"))

C.
1. Insert the following code segment at line 03.
HierarchicalDataTemplate template = new HierarchicalDataTemplate("Folder");
template.ItemsSource = new Binding("Name");
2. Insert the following code segment at line 05.
labelFactory.SetBinding(TextBlock.TextProperty, new Binding("Subfolders"))

D.
1. Insert the following code segment at line 03.
HierarchicalDataTemplate template = new HierarchicalDataTemplate("Folder");
template.ItemsSource = new Binding("Folder.Subfolders");
2. Insert the following code segment at line 05.
labelFactory.SetBinding(TextBlock.TextProperty, new Binding("Folder.Name"))



Leave a Reply 0

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