Exam 70-511 : Windows Applications Development with Microsoft .NET Framework 4 Part – 3

Question: You use Microsoft .NET Framework 4 to create a Windows Presentation Foundation (WPF) application. You write the following code segment.
public class Contact { private string _contactName;
public string ContactName {
get { return _contactName; }
set {
if (string.IsNullOrEmpty(value))
throw new ApplicationException("Contact name is required");
_contactName = value;
}
}
}

You add the following code fragment in a WPF window control.
<TextBox Text="{Binding Path=ContactName, ValidatesOnExceptions=True,
UpdateSourceTrigger=PropertyChanged}" />

The TextBox control is data-bound to an instance of the Contact class. You plan to implement an ErrorTemplate in the TextBox control. You need to ensure that the validation error message is displayed next to the TextBox control. Which code fragment should you use

  1. <ControlTemplate>
    <DockPanel>
    <AdornedElementPlaceholder Name="box" />
    <TextBlock Text="{Binding ElementName=box, Path=AdornedElement.(Validation.Errors)[0].ErrorContent}" Foreground="Red" />
    </DockPanel>
    </ControlTemplate>
  2. <ControlTemplate>
    <DockPanel>
    <AdornedElementPlaceholder Name="box" />
    <TextBlock Text="{Binding ElementName=box, Path=(Validation.Errors)[0].Exception.Message}" Foreground="Red" />
    </DockPanel>
    </ControlTemplate>
  3. <ControlTemplate>
    <DockPanel>
    <ContentControl Name="box" />
    <TextBlock Text="{Binding ElementName=box, Path=ContentControl.(Validation.Errors)[0].ErrorContent}" Foreground="Red" />
    </DockPanel>
    </ControlTemplate>
  4. <ControlTemplate>
    <DockPanel> <ContentControl Name="box" />
    <TextBlock Text="{Binding ElementName=box, Path=(Validation.Errors)[0].Exception.Message}" Foreground="Red" />
    </DockPanel> </ControlTemplate>

Correct Answer: 1


Question: You use Microsoft .NET Framework 4 to create a Windows Forms application. You have a dataset as shown in the following exhibit. You plan to add a DataGridView to display the dataset. You need to ensure that the DataGridView meets the following requirements: “Shows Order Details for the selected order.

  • Shows only Order Details for items that have UnitPrice greater than 20.
  • Sorts Products by ProductName

Which code segment should you use?

  1. ordersBindingSource.DataSource = productsBindingSource;
    ordersBindingSource.DataMember = "FK_Order_Details_Products";
    productsBindingSource.Filter = "UnitPrice > 20";
    productsBindingSource.Sort = "ProductName";
  2. productsDataGridView.DataSource = ordersBindingSource;
    productsBindingSource.Filter = "UnitPrice > 20";
    productsBindingSource.Sort = "ProductName";
  3. order_DetailsBindingSource.DataSource = ordersBindingSource; order_DetailsBindingSource.DataMember
    = "FK_Order_Details_Orders";
    order_DetailsBindingSource.Filter = "UnitPrice > 20";
    productsBindingSource.Sort = "ProductName";
  4. order_DetailsDataGridView.DataSource = ordersBindingSource; order_DetailsBindingSource.Filter =
    "UnitPrice > 20";
    productsBindingSource.Sort = "ProductName";

Correct Answer: 3


Question: You use Microsoft .NET Framework 4 to create a Windows Presentation Foundation (WPF) application. You plan to use an existing Windows Forms control named MyWinFormControl in the MyControls assembly. You need to ensure that the control can be used in your application. What should you do?

  1. Add the following code fragment to the application.
    <Window x:Class="HostingWfInWpf.Window1" xmlns="http: //schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:wf="clr-namespace:MyCompany.Controls;assembly=MyControls;" Title="HostingWfInWpf" >
    <Grid>
    <ElementHost>
    <wf:MyWinFormControl x:Name="control" />
    </ElementHost>
    </Grid> </Window>
  2. Add the following code fragment to the application.
    <Window x:Class="HostingWfInWpf.Window1" xmlns="http: //schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:wf="clr-namespace:MyCompany.Controls;assembly=MyControls;" Title="HostingWfInWpf" >
    <Grid>
    <WindowsFormsHost>
    <wf:MyWinFormControl x:Name="control" />
    </WindowsFormsHost>
    </Grid> </Window>
  3. Add the following code segment to the WindowsLoaded function.
    ElementHost host = new ElementHost();
    host.Dock = DockStyle.Fill;
    MyWinFormControl control = new MyWinFormControl();
    host.Child = control;
    this.Controls.Add(host);
  4. Add the following code segment to the WindowsLoaded function.
    Grid grid = new Grid();
    System.Windows.Forms.Integration.WindowsFormsHost host = new System.Windows.Forms.Integration.WindowsFormsHost();
    MyWinFormControl control = new MyWinFormControl();
    grid.Children.Add(host);

Correct Answer: 2


Question: You use Microsoft .NET Framework 4 to create a Windows Forms application. You plan to use a Windows Presentation Foundation (WPF) control of the UserControl1 type hosted in an ElementHost control named elementHost1. You write the following code segment. (Line numbers are included for reference only.)
01public class WPFInWinForms {
02public WPFInWinForms
03{
04InitializeComponent();
05
06}
07private void OnBackColorChange(object sender, String propertyName, object value)
08{
09ElementHost host = sender as ElementHost;
10System.Drawing.Color col = (System.Drawing.Color)value;
11SolidColorBrush brush = new SolidColorBrush(System.Windows.Media.Color.FromRgb(col.R, col.G, col.B));
12UserControl1 uc1 = host.Child as UserControl1;
13uc1.Background = brush;
14}
15}
You need to ensure that the application changes the background color of the hosted control when the background color of the form changes. Which code segment should you insert at line 05?

  1. elementHost1.PropertyMap.Remove("BackColor"); elementHost1.PropertyMap.Add("BackColor", new
    PropertyTranslator(OnBackColorChange));
  2. elementHost1.PropertyMap.Remove("Background"); elementHost1.PropertyMap.Add("Background", new
    PropertyTranslator(OnBackColorChange));
  3. elementHost1.PropertyMap.Add("BackColor", new PropertyTranslator(OnBackColorChange));
    elementHost1.PropertyMap.Apply("BackColor");
  4. elementHost1.PropertyMap.Add("Background", new PropertyTranslator(OnBackColorChange));
    elementHost1.PropertyMap.Apply("Background");

Correct Answer: 1


Question: You use Microsoft .NET Framework 4 to create a Windows Forms application. You need to allow the user interface to use the currently configured culture settings in the Control Panel. Which code segment should you use?

  1. Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;
  2. Thread.CurrentThread.CurrentCulture = Thread.CurrentThread.CurrentUICulture;
  3. Thread.CurrentThread.CurrentUICulture = CultureInfo.InstalledUICulture;
  4. Thread.CurrentThread.CurrentCulture = CultureInfo.InstalledUICulture;

Correct Answer: 1

Tagged . Bookmark the permalink.

2 Responses to Exam 70-511 : Windows Applications Development with Microsoft .NET Framework 4 Part – 3

  1. kavita says:

    Can u pls send me the e-Book for the exam 70-515.
    Myemailid
    kavitha_haripad@yahoo.com

Leave a Reply