Build User Interfaces

These questions are based on 70-502 CSHP – TS – Microsoft .NET Framework 3.5: Windows Presentation Foundation (C# .NET)
Microsoft
Self Test Software Practice Test


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


Single answer, multiple-choice


You are developing a Windows Presentation Foundation (WPF) application using the Microsoft .NET 3.5 Framework. You have designed the following custom control in the WPFCustomControl.xaml file:

<UserControl x:Class=”WPFCustomControls.LoginControl”
 xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation”
 xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml”
 Height=”300″ Width=”300″>
 <Grid Width=”296″>
 <TextBlock Text=”Username:” Height=”27″ Margin=”14,20,0,0″
 VerticalAlignment=”Top” HorizontalAlignment=”Left” Width=”114″ />
 <TextBox Name=”txtUsername” Margin=”102.5,70,96,0″
 Height=”21″ VerticalAlignment=”Top” />
 <TextBlock Text=”Password:” Height=”18″ Margin=”14,73,0,0″
 VerticalAlignment=”Top” HorizontalAlignment=”Left” Width=”78″ />
 <TextBox Name=”txtPassword” Height=”19″
 Margin=”106,20,96,0″ VerticalAlignment=”Top” />
 <Button Click=”Button_Click”
 Margin=”82,131,144,146″>Login</Button>
 </Grid>
</UserControl>

The custom control is located in a different assembly named WPFCustomControls. You want to place the custom control in the following window:

<Window x:Class=”Tester.MainWindow”
 xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation”
 xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml>
 <!–Contents –>
</Window>

You add a reference to the WPFCustomControls assembly. What should you do next?



  1. Add the following property to the Window element:
    xmlns:cust=”clr-namespace:WPFCustomControls”
  2. Add the following property to the Window element:
    xmlns:cust=”clr-namespace:WPFCustomControls; assembly=WPFCustomControls”
  3. Add the following markup in the Window element:
    <WPFCustomControl xmlns=”clr-namespace:WPFCustomControls” />
  4. Add the following markup in the Window element:
    <WPFCustomControl xmlns=” clr-namespace:WPFCustomControls;assembly=WPFCustomControls” />

Answer:
B. Add the following property to the Window element:
     xmlns:cust=”clr-namespace:WPFCustomControls; assembly=WPFCustomControls”


Tutorial:
You should add the following property to the Window element to include a custom control in the main window:


xmlns:cust=”clr-namespace:WPFCustomControls; assembly=WPFCustomControls”


The clr-namespace matches the namespace of the user control, WPFCustomControls. In this scenario, the user code is in a different assembly, so you should also specify the assembly name in the namespace declaration. The XAML namespace declaration does not include…


cmadmin

ABOUT THE AUTHOR

Posted in Uncategorized|

Comment:

Powered by WebDesk