Microsoft Exam Questions

What should you do ?

You are developing a Windows Presentation Foundation (WPF) application that displays opportunities from List<T.. class named Lead. The Lead class contains the properties Title and Revenue.

You add a DataGrid control named dgQualifiedLeads to the MainWindow.xaml file. You set the ItemsSource property to Leads as follows.

ICollectionView Leads;
public MainWindow()
{
IntializeComponent();
Leads = CollectionViewSource.GetDefaultView(
new List<Lead>(
new Lead[]
{
new Lead() { Title = “Title1″, Revenue=”1234.33”},
new Lead() { Title = “Title2″, Revenue=”1234.33”},
new Lead() { Title = “Title3″, Revenue=”1234.33”},
new Lead() { Title = “Title4″, Revenue=”1234.33”},
new Lead() { Title = “Title5″, Revenue=”1234.33”}
}
));

dgQualifiedLeads.ItemsSource = Leads;
}

You need to ensure that CollectionViewSource is used to filter the list to display only Lead objects with revenue …

What should you do ?

A.
Insert the following code at Line 18
Leads.Filter = new Predicate<object>(FilterOut);
Add the following code segment to the code-behind of the MainWindow.xaml file.
public bool FilterOut(object item)
{
Lead lead = item as Lead;
return (lead.Revenue < 1000d) ? true : false;
}

B.
Insert the following code at Line 18
Leads.Filter = new Predicate<object>(FilterOut);
Add the following code segment to the code-behind of the MainWindow.xaml file.
public bool FilterOut(object item)
{
Lead lead = item as Lead;
return (lead.Revenue > 1000d) ? false : true;
}

C.
Insert the following code at Line 18
Leads.Filter = new Predicate<object>((s) => { ((Lead) s).Revenue > 1000d });

D.
Insert the following code at Line 18
Leads.SortDescriptions.Add(new SortDescription(“Revenue”, ListSortDirection.Ascending));