googlebot
Buy Differin Gel Online
ADVERTISEMENT
Email this article



Use comma or semi-colon to seperate mutltiple emails.




Learn About Microsoft .NET Framework 3.5

BackBy Certification Magazine — February 19, 2009

The following are questions from MeasureUp’s Practice Test to help you prepare for the C# version of Microsoft Exam 70-502: Microsoft .NET Framework 3.5: Windows Presentation Foundation (WPF) Application Development

The audience for this exam includes individuals responsible for developing Windows-based software applications. Experience using Visual Studio 2008 and .NET Framework 3.5 and in developing and deploying WPF applications will help you prepare for this exam. MeasureUp offers practice tests for both the C# version and the VB version of this exam.


Objective: Configure and deploy WPF applications.
Sub-objective: Manage upgrades.

Single answer, multiple-choice

You recently deployed version 1.0.0.0 of a Microsoft Windows Presentation Foundation (WPF) application by using ClickOnce. You now deploy version 1.0.2.0 of the same application to a different location. The following files exist:

•    Crm.exe
•    Crm.exe.config
•    Crm.application
•    Crm.exe.manifest
•    Crm.exe.config.deploy

You need to require users who recently installed the application to use the new version. What should you do?

A.    Specify the following data in the Crm.application file:
B.    Specify the following data in the Crm.exe.manifest file:
C.    Specify the following data in the Crm.exe.config.deploy file:
D.    Specify the following data in the Crm.exe.config file:

Answer:
A

Tutorial:
You should specify the following data in the Crm.application file:

This configures the deployment manifest to require users to use version 1.0.2.0 of the application. Because the beforeApplicationStartup element is specified as a child of the update element, the application will check for updates before it starts. This helps ensure the user does not launch a previous version of the application.

You should not specify the following data in the Crm.exe.manifest file:

This file represents the application manifest. To configure updates, you must modify the deployment manifest. The application manifest stores information about the application, such as required permissions, associated files and dependencies.

You should not specify the following data in the Crm.exe.config.deploy file:

This file represents a deployment file for Crm.exe.config.

You should not specify the following data in the Crm.exe.config file:

This file represents an application configuration file.

References:
Choosing a ClickOnce Update Strategy, MSDN, http://msdn2.microsoft.com/en-us/library/s22azw1e.aspx
Introduction to ClickOnce Deployment, MSDN, http://msdn2.microsoft.com/en-us/vbasic/ms789088.aspx


Objective: Create a WPF application.
Sub-objective: Configure page-based navigation.

Single answer, multiple-choice

You are developing a Microsoft WPF application. An Extensible Application Markup Language (XAML) page named Invoice.xaml uses the following code-behind class definition:

public partial class Invoice : Page
{
public Invoice(int invoiceNumber)
{
}
}

This page allows users to view an invoice. The value passed to the constructor determines the invoice the page should display. You need to use a Hyperlink control on another page to navigate to the invoice page and display invoice 100. What should you do?

A.    Configure the Hyperlink control as follows:
View Invoice

B.    Handle the Click event of the Hyperlink control. Add the following code to the event handler:
Uri invoiceUri = new Uri("Invoice.xaml#100");
NavigationService service = NavigationService.GetNavigationService(this);
service.Navigate(invoiceUri);

C.    Handle the Click event of the Hyperlink control. Add the following code to the event handler:
Invoice invoicePage = new Invoice(100);
this.NavigationService.Navigate(invoicePage);

D.    Configure the Hyperlink control as follows:
View Invoice

Answer:
C

Tutorial:
You should handle the Click event of the Hyperlink control and add the following code to the event handler:

Invoice invoicePage = new Invoice(100);
this.NavigationService.Navigate(invoicePage);

This code first creates an instance of the Invoice class, passing the value 100 to the constructor. Next it accesses the current page’s NavigationService instance. Finally, it calls the Navigate method of that instance, passing to it the instance of the page to display. When a page contains a non-default constructor, you must use the NavigationService class to navigate to that page.

You should not configure the Hyperlink control as follows:

View Invoice

This XAML causes the Hyperlink control to initiate navigation to a XAML element that has the XAML-defined name 100 on the Invoice.xaml page.

You should not use the following code:

Uri invoiceUri = new Uri("Invoice.xaml#100");
NavigationService service = NavigationService.GetNavigationService(this);
service.Navigate(invoiceUri);

This code creates a uniform resource identifier (URI) that points to a XAML element that has the XAML-defined name 100 on the Invoice.xaml page. The GetNavigationService method of the NavigationService class allows you to retrieve a specific NavigationService instance. However, passing the current page instance to this method is equivalent to accessing the page’s NavigationService property.

You should not configure the Hyperlink control as follows:

View Invoice

This XAML uses the query string syntax as the value of the NavigateUri property. This syntax does not work for XAML pages.

References:
Navigation Overview, MSDN,

http://msdn2.microsoft.com/en-us/library/ms750478.aspx


How to: Navigate to a Page, MSDN, http://msdn2.microsoft.com/en-us/library/ms743613.aspx


Objective: Building user interfaces.
Sub-objective: Create user and custom controls.

Single answer, multiple-choice

You are developing a WPF custom control. The control must contain a MediaElement property named Media that supports WPF data binding and animation. You need to define the class that represents the control. Which code segment should you use?

A.    public class MediaPlayer : System.Windows.Controls.Control
{
  public static readonly DependencyProperty MediaProperty = DependencyProperty.Register("Media", typeof(MediaElement), typeof(MediaPlayer));

  public MediaElement Media
  {
    get { return (MediaElement)GetValue(MediaProperty); }
    set { SetValue(MediaProperty, value); }
  }
}

B.    public class MediaPlayer : System.Windows.Controls.Control
{
  public static readonly DependencyProperty MediaProperty = DependencyProperty.Register("Media", typeof(MediaElement), typeof(MediaPlayer));
  private MediaElement mediaElement;

  public MediaElement Media
  {
    get { return mediaElement; }
    set { mediaElement = value; }
  }
}

C.    public class MediaPlayer : System.Windows.Controls.Control
{
  private MediaElement mediaElement;

  [Bindable(BindableSupport.Yes)]
  public MediaElement Media
  {
    get { return mediaElement; }
    set { mediaElement = value; }
  }
}

D.    public class MediaPlayer : System.Windows.Controls.Control
{
  private MediaElement mediaElement;

  [Bindable(true)]
  public MediaElement Media
  {
    get { return mediaElement; }
    set { mediaElement = value; }
  }
}

Answer:
A

Tutorial:
You should use the following code segment:

public class MediaPlayer : System.Windows.Controls.Control
{
  public static readonly DependencyProperty MediaProperty = DependencyProperty.Register("Media", typeof(MediaElement), typeof(MediaPlayer));

  public MediaElement Media
  {
    get { return (MediaElement)GetValue(MediaProperty); }
    set { SetValue(MediaProperty, value); }
  }
}

This code defines the Media property as a dependency property. Only dependency properties support WPF data binding. To create a dependency property, you must call the Register method of the DependencyProperty class and save the returned DependencyProperty instance to a static variable. In the get and set property accessors, you must call the GetValue and SetValue methods, respectively.

The GetValue method accepts a DependencyProperty instance that represents the dependency property whose value should be retrieved. The SetValue method also accepts a DependencyProperty instance, in addition to an Object instance that represents the value to which the property is to be set.

You should not use the following code segment:

public class MediaPlayer : System.Windows.Controls.Control
{
  public static readonly DependencyProperty MediaProperty = DependencyProperty.Register("Media", typeof(MediaElement), typeof(MediaPlayer));
  private MediaElement mediaElement;

  public MediaElement Media
  {
    get { return mediaElement; }
    set { mediaElement = value; }
  }
}

Although this code registers a dependency property, it does not call the GetValue and SetValue methods to get and set property values, respectively.

You should not use the following code segment:

public class MediaPlayer : System.Windows.Controls.Control
{
  private MediaElement mediaElement;

  [Bindable(BindableSupport.Yes)]
  public MediaElement Media
  {
    get { return mediaElement; }
    set { mediaElement = value; }
  }
}

This code does not create a dependency property. It simply stores the value of the property in a private field. Also, the Bindable attribute does not cause a property to support WPF animation.

You should not use the following code segment:

public class MediaPlayer : System.Windows.Controls.Control
{
  private MediaElement mediaElement;

  [Bindable(true)]
  public MediaElement Media
  {
    get { return mediaElement; }
    set { mediaElement = value; }
  }
}

This code does not create a dependency property. It simply stores the value of the property in a private field. Also, the Bindable attribute does not cause a property to support WPF animation.

References:
Control Authoring Overview, MSDN, http://msdn2.microsoft.com/en-us/library/ms745025.aspx
How to: Implement a Dependency Property, MSDN, http://msdn2.microsoft.com/en-us/library/ms750428.aspx
Dependency Properties Overview, MSDN, http://msdn2.microsoft.com/en-us/library/ms752914.aspx
Custom Dependency Properties, MSDN, http://msdn2.microsoft.com/en-us/library/ms753358.aspx


Objective: Add and manage content.
Sub-objective: Manage images.

Single answer, multiple-choice

You are developing a Microsoft WPF application. The following XAML resource is defined in the application definition file:

You need to write code to display a 180-degree rotation of this bitmap in an Image control. Which code segment should you use?

A.    BitmapImage bitmap = new BitmapImage(new Uri("pack://application:,,,/ResourceImage"));
bitmap.Rotation = Rotation.Rotate180;
TransformedBitmap transformedBitmap = new TransformedBitmap();
Image image = new Image();
image.Source = transformedBitmap;

B.    BitmapImage bitmap = (BitmapImage)Application.Current.Resources["ResourceImage"];
RotateTransform transform = new RotateTransform(180);
TransformedBitmap transformedBitmap = new TransformedBitmap(bitmap, transform);
Image image = new Image();
image.Source = transformedBitmap;

C.    BitmapImage bitmap = (BitmapImage)Application.Current.Resources["ResourceImage"];
Transform transform = new Transform(TransformKind.Rotate,180);
TransformedBitmap transformedBitmap = new TransformedBitmap(bitmap, transform);
Image image = new Image();
image.Source = transformedBitmap;

D.    BitmapImage bitmap = new BitmapImage(new Uri("pack://application:,,,/ResourceImage"));
RotateTransform transform = new RotateTransform(180);
TransformedBitmap transformedBitmap = new TransformedBitmap(bitmap, transform);
Image image = new Image();
image.Source = bitmap;

Answer:
B

Tutorial:
You should use the following code segment:

BitmapImage bitmap = (BitmapImage)Application.Current.Resources["ResourceImage"];
RotateTransform transform = new RotateTransform(180);
TransformedBitmap transformedBitmap = new TransformedBitmap(bitmap, transform);
Image image = new Image();
image.Source = transformedBitmap;

This code first retrieves the BitmapImage instance from the application-scope resources. It then creates a TransformedBitmap instance that is chained to the original BitmapImage instance. The TransformedBitmap instance uses a RotateTransform instance to rotate the bitmap 180 degrees. The Image control uses the TransformedBitmap instance as its source because that instance represents the rotated bitmap.

You should not use the following code segment:

BitmapImage bitmap = new BitmapImage(new Uri("pack://application:,,,/ResourceImage"));
bitmap.Rotation = Rotation.Rotate180;
TransformedBitmap transformedBitmap = new TransformedBitmap();
Image image = new Image();
image.Source = transformedBitmap;

This code attempts to create a BitmapImage instance by retrieving the image as a binary resource. However, in this scenario, the bitmap is defined as a logical resource in the application definition file. Also, this code sets the Source property of an Image control to a TransformedBitmap instance that is not associated with a source bitmap or a transformation.

You should not use the following code segment:

BitmapImage bitmap = (BitmapImage)Application.Current.Resources["ResourceImage"];
Transform transform = new Transform(TransformKind.Rotate,180);
TransformedBitmap transformedBitmap = new TransformedBitmap(bitmap, transform);
Image image = new Image();
image.Source = transformedBitmap;

Although this code correctly retrieves the bitmap and assigns it to the Source property of the Image instance, the transform applied to the bitmap is invalid. The Transform class is abstract, and there is no TransformKind enumeration. Instead you should use the RotateTransform class to perform the transformation.

You should not use the following code segment:

BitmapImage bitmap = new BitmapImage(new Uri("pack://application:,,,/ResourceImage"));
RotateTransform transform = new RotateTransform(180);
TransformedBitmap transformedBitmap = new TransformedBitmap(bitmap, transform);
Image image = new Image();
image.Source = bitmap;

This code attempts to create a BitmapImage instance by retrieving the image as a binary resource. However, in this scenario, the bitmap is defined as a logical resource in the application definition file. Also, although this code creates a TransformedBitmap instance, it sets the Source property of the Image control to the BitmapImage instance that represents the original bitmap. The original bitmap is not rotated.

References:
Imaging Overview, MSDN, http://msdn2.microsoft.com/en-us/library/ms748873.aspx
How to: Chain BitmapSource Objects Together, MSDN, http://msdn2.microsoft.com/en-us/library/ms743719.aspx
How to: Apply a Transform to a BitmapImage, MSDN, http://msdn2.microsoft.com/en-us/library/aa970271.aspx


Objective: Bind to data sources.
Sub-objective: Bind to a data collection.

Single answer, multiple-choice

You are developing a Microsoft WPF application. A ListBox control named employeeListBox exists in the XAML file for a window. You write the following code to create a collection of employees:

EmployeeCollection employees = new EmployeeCollection();
employees.Add(new Employee(){Name = "Employee 1"});
employees.Add(new Employee(){Name = "Employee 2"});
employees.Add(new Employee(){Name = "Employee 3"});
employeeListBox.DataContext = employees;

You need to configure the ListBox control to display the value of the Name property of each Employee instance in the collection. Which XAML content should you use?

A.    
Name="employeeListBox"
ItemsSource="{Binding ElementName=Name}"/>

B.    
Name="employeeListBox"
ItemsSource="{Binding Source=Employee.Name}"/>

C.    
Name="employeeListBox"
ItemsSource="{Binding Path=Name}"/>

D.    
Name="employeeListBox"
ItemsSource="{Binding Source=Employee}"/>

Answer:
C

Tutorial:
You should use the following XAML content:


Name="employeeListBox"
ItemsSource="{Binding Path=Name}"/>

This XAML sets the ItemsSource property to a value that uses the Binding markup extension syntax. The Path property of the Binding class specifies the source value of a binding. Typically, you would also set either the Source property or the ElementName property to specify the binding source. However, in this scenario, the DataContext property of the ListBox control is set. When the DataContext property is set, a binding uses its value as the binding source. This allows child controls to reuse the binding source associated with a parent control.

You should not use the following XAML content:


Name="employeeListBox"
ItemsSource="{Binding ElementName=Name}"/>

This XAML sets the ElementName property to Name, and it does not set the Path property. The ElementName property specifies a XAML element to which a binding applies. In this scenario, the binding does not apply to another XAML element.

You should not use the following XAML content:


Name="employeeListBox"
ItemsSource="{Binding Source=Employee.Name}"/>

This XAML sets the Source property to Employee.Name, and it does not set the Path property. The Source property specifies the instance of an object being bound. In this scenario, because the DataContext property of the ListBox control is set, you should not set the Source property of the Binding class.

You should not use the following XAML content:


Name="employeeListBox"
ItemsSource="{Binding Source=Employee}"/>

This XAML sets the Source property to Employee, and it does not set the Path property. The Source property specifies the instance of an object being bound. In this scenario, because the DataContext property of the ListBox control is set, you should not set the Source property of the Binding class.

References:
Binding Declarations Overview, MSDN, http://msdn2.microsoft.com/en-us/library/ms752300.aspx

How to: Specify the Binding Source, MSDN,

http://msdn2.microsoft.com/en-us/library/ms746695.aspx

How to: Bind to a Collection and Display Information Based on Selection, MSDN, http://msdn2.microsoft.com/en-us/library/aa970558.aspx
Data Binding Overview, MSDN, http://msdn2.microsoft.com/en-us/library/ms752347.aspx
Viewed 8790 times.
SPONSORED LINKS
gps systems used