Which XAML fragment should you use?

You are developing a Silverlight 4 application. You define an Invoice object according to the following code segment:

public class Invoice
{
public int InvoiceId { get; set; }
public double Amount { get; set; }
public Supplier { get; set; }
public DateTime InvoiceDate { get; set; }
public DateTime PayDate { get; set; }
public string InvoiceDescription { get; set; }
}
You need to display a list of invoices that have the following properties displayed on each line: InvoiceId, Amount, and InvoiceDate. Which XAML fragment should you use?

You are developing a Silverlight 4 application. You define an Invoice object according to the following code segment:

public class Invoice
{
public int InvoiceId { get; set; }
public double Amount { get; set; }
public Supplier { get; set; }
public DateTime InvoiceDate { get; set; }
public DateTime PayDate { get; set; }
public string InvoiceDescription { get; set; }
}
You need to display a list of invoices that have the following properties displayed on each line: InvoiceId, Amount, and InvoiceDate. Which XAML fragment should you use?

A.
<ListBox x:Name=”InvoiceListBox”>
<StackPanel Orientation=”Horizontal”>
<TextBlock Text=”{Binding Path=InvoiceId}” />
<TextBlock Text=”{Binding Path=Amount}” />
<TextBlock Text=”{Binding Path=InvoiceDate}” />
</StackPanel>
</ListBox>

B.
<ListBox x:Name=”InvoiceListBox”>
<StackPanel Orientation=”Horizontal”>
<ListBoxItem>
<TextBlock Text=”{Binding Path=InvoiceId}” />
</ListBoxItem>
<ListBoxItem>
<TextBlock Text=”{Binding Path=Amount}” />
</ListBoxItem>
<ListBoxItem>
<TextBlock Text=”{Binding Path=InvoiceDate}” />
</ListBoxItem>
</StackPanel>
</ListBox>

C.
<ListBox x:Name=”InvoiceListBox”>
<ListBox.Items>
<ItemsPanelTemplate>
<StackPanel Orientation=”Horizontal”>
<TextBlock Text=”{Binding Path=InvoiceId}” />
<TextBlock Text=”{Binding Path=Amount}” />
<TextBlock Text=”{Binding Path=InvoiceDate}” />
</StackPanel>
</ItemsPanelTemplate>
</ListBox.Items>
</ListBox>

D.
<ListBox x:Name=”InvoiceListBox”>
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation=”Horizontal”>
<TextBlock Text=”{Binding Path=InvoiceId}” />
<TextBlock Text=”{Binding Path=Amount}” />
<TextBlock Text=”{Binding Path=InvoiceDate}” />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>



Leave a Reply 0

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