PrepAway - Latest Free Exam Questions & Answers

Category: 70-506

Exam 70-506: TS: Silverlight 4, Development

Which two actions should you perform?

You are developing an application by using Silverlight 4 and Microsoft .NET Framework 4.
You create a control named MyControl in the application. Each instance of the control contains a list of FrameworkElement objects.
You add the following code segment. (Line numbers are included for reference only.)

01 public class MyControl : Control
02 {
03
04 public List<FrameworkElement> ChildElements
05 {
06 get {
07 return List<FrameworkElement>)GetValue(MyControl.ChildElementsProperty);
08 }
09 }
10
11 public MyControl()
12 {
13
14 }
15 static MyControl()
16 {
17
18 }
19 }

You need to create the ChildElementsProperty dependency property. You also need to initialize the property by using an empty list of FrameworkElement objects.
Which two actions should you perform? (Each correct answer presents part of the solution. Choose two.)

Which code segment you add at line 03?

You are developing an application by using Silverlight 4 and Microsoft .NET Framework 4.
You add the following code segment. (Line numbers are included for reference only.)

01 public class MyControl : Control
02 {
03
04 public string Title
05 {
06 get { return (string)GetValue(TitleProperty); }
07 set { SetValue(TitleProperty, value); }
08 }
09 }

You need to create a dependency property named TitleProperty that allows developers to set the Title. You also need to ensure that the default value of the TitleProperty
dependency property is set to Untitled. Which code segment you add at line 03?

What should you do?

You are developing an application by using Silverlight 4 and Microsoft .NET Framework 4.
You add a BackgroundWorker object named worker to the application. You also add a CheckBox control named checkBox and a TextBlock control named statusTextBlock.
You add the follo wing code segment. (Line numbers are included for reference only.)

01 public MainPage()
02 {
03 InitializeComponent();
04 worker.WorkerReportsProgress = true;
05 worker.DoWork += new DoWorkEventHandler(worker_DoWork);
06 worker.ProgressChanged += new ProgressChangedEventHandler(worker_ProgressChanged);
07 }
08 private void worker_DoWork(object sender, DoWorkEventArgs e)
09 {
10 for (int i = 0; i < 100; i++) {
11 bool isChecked = checkBox.IsChecked.HasValue && checkBox.IsChecked.Value;
12 ExecuteLongRunningProcessStep(isChecked);
13 worker.ReportProgress(i);
14 }
15 }
16 private void worker_ProgressChanged(object sender, ProgressChangedEventArgs e)
17 {
18 statusTextBlock.Text = e.ProgressPercentage + “%”;
19 }

You attempt to run the application. You receive the following error message: “Invalid crossthread access.”
You need to ensure that worker executes successfully. What should you do?

Which code segment should you use to replace line 11?

You are developing an application by using Silverlight 4 and Microsoft .NET Framework 4. You add a BackgroundWorker object named worker to the application.
You add the following code segment. (Line numbers are included for reference only.)

01 public MainPage()
02 {
03 InitializeComponent();
04 worker.WorkerSupportsCancellation = true;
05 worker.DoWork += new DoWorkEventHandler(worker_DoWork);
06 worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker_Completed)
07 }
08 private void worker_DoWork(object sender, DoWorkEventArgs e)
09 {
10 for (int i = 0; i < 100; i++) {
11 InvokeLongRunningProcessStep();
12 }
13 }

You need to ensure that worker can be properly canceled. Which code segment should you use to replace line 11?

Which two actions should you perform?

You are developing an application by using Silverlight 4 and Microsoft .NET Framework 4.
You create a Windows Communication Foundation (WCF) Data Service. You add a service reference to the WCF Data Service named NorthwindEntities in the Silverlight application. You also add a CollectionViewSource object named ordersViewSource in the Silverlight application.
You add the following code segment. (Line numbers are included for reference only.)

01 void getOrders_Click(object sender, RoutedEventArgs e)
02 {
03 var context = new NorthwindEntities();
04
05 var query = from order in context.Orders
06 select order;
07
08 }

You need to retrieve the Orders data from the WCF Data Service and bind the data to the ordersViewSource object. Which two actions should you perform?
(Each correct answer presents part of the solution. Choose two.)

Which code segment should you replace at lines 02 and 03?

You are developing an application by using Silverlight 4 and Microsoft .NET Framework 4. The application contains the following XAML fragment.
<TextBlock x:Name=”QuoteOfTheDay” />
The application calls a Windows Communication Foundation (WCF) service named MyService that returns the quote of the day and assigns it to the QuoteOfTheDay TextBlock.
The application contains the following code segment. (Line numbers are included for reference only.)

01 var client = new MyService.MyServiceClient();
02 client.GetQuoteOfTheDayCompleted += (s, args) => QuoteOfTheDay.Text = args.Result;
03 client.GetQuoteOfTheDayAsync();

You need to handle errors that might occur as a result of the service call. You also need to provide a default value of “Unavailable” when an error occurs.
Which code segment should you replace at lines 02 and 03?

Which code segment should you add at line 03?

You are developing an application by using Silverlight 4 and Microsoft .NET Framework 4. You create a new user control in the application. You add the following XAML fragment
to the control:

<StackPanel KeyDown=”App_KeyDown” Orientation=”Vertical”>
<TextBox x:Name=”firstName” />
<TextBox x:Name=”lastName” />
<TextBox x:Name=”address” />
</StackPanel>

You add the following code segment in the code behind file of the control. (Line numbers are included for reference only.)

01 private void App_KeyDown(object sender, KeyEventArgs e)
02 {
03
04 }
05
06 private void FirstAndLastNameKeyDown()
07 {
08 …
09 }

You need to ensure that the First And LastName KeyDown method is invoked when a key is pressed while the focus is on the firstName or lastName TextBox controls. You also need to ensure that the default behavior of the controls remains unchanged.
Which code segment should you add at line 03?

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?


Page 9 of 10« First...678910