1.You are creating Windows Presentation Foundation application by using
Microsoft .NET Framework 3.5.
The application has a TreeView class that builds the directory tree for a
given directory.
You write the following class that represents a directory.
Class Folder
Public ReadOnly Property Name() As String
Get
…
End Get
End Property
Public ReadOnly Property Subfolders() As List(Of Folder)
Get
…
End Get
End Property
End Class
You write the following code segment. (Line numbers are included for
reference only.)
01 Dim tree As New TreeView()
02 Dim folder As New Folder(“C:\”)
03
04 Dim labelFactory As New
05 FrameworkElementFactory(GetType(TextBlock))
06
07 template.VisualTree = labelFactory
08 tree.ItemTemplate = template
09 tree.ItemsSource = folder.Subfolders
You need to ensure that the TreeView class displays nodes that correspond to
the child folders of the C:\ drive.
Which code segments should you insert at lines 03 and 06?
A: 1. Insert the following code segment at line 03. Dim template As New
HierarchicalDataTemplate(folder)template.ItemsSource = New Binding
(“Subfolders”) 2. Insert the following code segment at line 06.
labelFactory.SetBinding(TextBlock.TextProperty, New Binding(“Name”))
B: 1. Insert the following code segment at line 03. Dim template As New
HierarchicalDataTemplate(GetType(Folder))template.ItemsSource = New Binding
(“Subfolders”) 2. Insert the following code segment at line 06.
labelFactory.SetBinding(TextBlock.TextProperty, New Binding(“Name”))
C: 1. Insert the following code segment at line 03. Dim template As New
HierarchicalDataTemplate(“Folder”)template.ItemsSource = New Binding(“Name”)
2. Insert the following code segment at line 06. labelFactory.SetBinding
(TextBlock.TextProperty, _New Binding(“Subfolders”))
D: 1. Insert the following code segment at line 03. Dim template As New
HierarchicalDataTemplate(“Folder”)template.ItemsSource = New Binding
(“Folder.Subfolders”) 2. Insert the following code segment at line 06.
labelFactory.SetBinding(TextBlock.TextProperty, _New Binding(“Folder.Name”))
Correct Answers: B
2.You are creating a Windows Presentation Foundation application by using
Microsoft .NET Framework 3.5. You need to display the title of the page in
a TextBlock control that is placed at the top of a page. Which XAML code
fragment should you use?
A: <TextBlock Text=”{Binding Path=Title, Source=Page}”/>
B: <TextBlock Text=”{Binding Path=Title, Source={x:Type Page}}”/>
C: <TextBlock Text=”{Binding Path=Title, RelativeSource= {RelativeSource
FindAncestor, AncestorType={x:Type Page}}}”/>
D: <TextBlock Text=”{Binding Path=Title, RelativeSource={RelativeSource
Self}}”/>
Correct Answers: C
3.You are creating a Windows Presentation Foundation application by using
Microsoft .NET Framework 3.5.
You plan to add a check box to a window of the application. The check box
must display the associated content and the text “Yes” or “No” instead of
the check mark.
You write the following XAML code fragment. (Line numbers are included for
reference only.)
01 <Window.Resources>
02 <ControlTemplate x:Key=”check” TargetType=”CheckBox”>
03 <DockPanel Name=”dock”>
04
05 <TextBlock Name=”text”/>
06 </DockPanel>
07 <ControlTemplate.Triggers>
08 <Trigger Property=”IsChecked” Value=”False”>
09
10 </Trigger>
11 </ControlTemplate.Triggers>
12 </ControlTemplate>
13 </Window.Resources>
14 <CheckBox Content=”Is Active” Template=”{StaticResource
15 check}” />
You need to ensure that the check box displays the text “Is Active No” in
the cleared state.
What should you do?
A: Insert the following XAML code fragment at line 04. <ContentPresenter />
Insert the following XAML code fragment at line 09. <Setter
TargetName=”text” Property=”Text” Value=”No”/>
B: Insert the following XAML code fragment at line 04. <ContentPresenter />
Insert the following XAML code fragment at line 09. <Setter
Property=”TextBlock.Text” Value=”No”/>
C: Insert the following XAML code fragment at line 04. <ContentPresenter
Content=”{TemplateBinding Content}” /> Insert the following XAML code
fragment at line 09. <Setter Property=”TextBlock.Text” Value=”No”/>
D: Insert the following XAML code fragment at line 04. <ContentPresenter
Content=”{Binding RelativeSource={RelativeSource self}, Path=Content}” />
Insert the following XAML code fragment at line 09. <Setter
TargetName=”text” Property=”Text” Value=”No”/>
Correct Answers: A 70-648 mb2-631 MB6-821
4.You are creating a Windows Presentation Foundation application by using
Microsoft .NET Framework 3.5. The application contains a custom event
handler. You need to ensure that the custom event handler always executes
when the event occurs, even if the Handled property is set to true. What
should you do?
A: Set the HandledEventsToo property to true in the event definition code
segment.
B: Set the HandledEventsToo property to false in the event definition code
segment.
C: Set the HandledEventsToo property to true in the event definition XAML
code fragment.
D: Set the HandledEventsToo property to false in the event definition XAML
code fragment.
Correct Answers: A
5.You create a form by using Windows Presentation Foundation and Microsoft
.NET Framework 3.5. The form contains a status bar. You plan to add a
ProgressBar control to the status bar. You need to ensure that the
ProgressBar control displays the progress of a task for which you cannot
predict the completion time. Which code segment should you use?
A: progbar.IsIndeterminate = True
B: progbar.IsIndeterminate = False
C: progbar.HasAnimatedProperties = True
D: progbar.HasAnimatedProperties = False
Correct Answers: A
6.You are creating a Windows Presentation Foundation application.
You create a window for the application. The application contains an audio
file named AudioFileToPlay.wav.
You need to ensure that the following requirements are met:
The audio file is played each time you click the client area of the
window.
The window provides optimal performance when the audio file is being
played.
What should you do?
A: Add the following XAML line of code to the window. <MediaElement
Source=”AudioFileToPlay.wav” />
B: Add the following code segment to the window constructor method in the
code-behind file. Dim player As New SoundPlayer()player.SoundLocation =
“AudioFileToPlay.wav”player.Play()
C: Add the following code segment to the window MouseDown method in the
code-behind file. Dim player As New MediaElement()player.Source = New Uri
(“AudioFileToPlay.wav”, UriKind.Relative)player.LoadedBehavior =
MediaState.Manualplayer.Play()
D: Add the following XAML code fragment to the window. <Window.Triggers>
<EventTrigger RoutedEvent=”Window.MouseDown”> <EventTrigger.Actions>
<SoundPlayerAction Source=”AudioFileToPlay.wav”/> </EventTrigger.Actions>
</EventTrigger></Window.Triggers>
Correct Answers: D N10-004 642-655 70-236 70-291 70-284
7.You are creating a Windows Presentation Foundation application by using
Microsoft .NET Framework 3.5. You implement validation for a data bound
text box control. When a user enters an invalid value in the text box, the
border of the text box turns red. You need to update the application so that
both the border and the text of the text box control turn red when an
invalid value is entered. What should you do?
A: Use a custom control template.
B: Create a custom validation rule.
C: Add an exception handler to the code-behind file.
D: Add two validation rules to the ValidationRules element.
Correct Answers: A
8.You are creating a Windows Presentation Foundation application by using
Microsoft .NET Framework 3.5.
You write the following code segment (Line numbers are included for
reference only).
01 Dim content As Object
02 Dim fileName As String = “theFile”
03 Using xamlFile As New FileStream(fileName & “.xaml”, _
04 FileMode.Open, FileAccess.Read)
06 content = TryCast(XamlReader.Load(xamlFile), Object)
07 End Using
08 Using container As Package = Package.Open(fileName & “.xps”, _
09 FileMode.Create)
10
11 End Using
You need to ensure that the following requirements are met:
The application converts an existing flow document into an XPS document.
The XPS document is generated by using the flow document format.
The XPS document has the minimum possible size.
Which code segment should you insert at line 10?
A: Using xpsDoc As New XpsDocument(container, _ CompressionOption.SuperFast)
Dim rsm As XpsSerializationManager = New _
System.Windows.Xps.XpsSerializationManager(New _ XpsPackagingPolicy
(xpsDoc), False) rsm.SaveAsXaml(paginator)End Using
B: Using xpsDoc As New XpsDocument(container, _ CompressionOption.SuperFast)
Dim rsm As New XpsSerializationManager(New _ XpsPackagingPolicy(xpsDoc),
False) rsm.Commit()End Using
C: Using xpsDoc As New XpsDocument(container, _ CompressionOption.Maximum)
Dim rsm As New XpsSerializationManager(New _ XpsPackagingPolicy(xpsDoc),
False) Dim paginator As DocumentPaginator = (CType(content, _
IDocumentPaginatorSource)).DocumentPaginator rsm.SaveAsXaml(paginator)End
Using
D: Using xpsDoc As New XpsDocument(container, _ CompressionOption.SuperFast)
Dim rsm As New XpsSerializationManager(New _ XpsPackagingPolicy(xpsDoc),
False) Dim paginator As DocumentPaginator = (CType(content, _
IDocumentPaginatorSource)).DocumentPaginator rsm.SaveAsXaml(paginator)End
Using
Correct Answers: C
9.You create a Windows Presentation Foundation application by using
Microsoft .NET Framework 3.5. The application includes a window that
displays a rectangle. You need to transform the rectangle by rotating it 45
degrees. Which XAML code fragment should you use?
A: <Rectangle.RenderTransform> <TranslateTransform X=”45″ Y=”45″
/></Rectangle.RenderTransform>
B: <RectangleGeometry.Transform> <RotateTransform CenterX=”40″ CenterY=”70″
Angle=”45″ /></RectangleGeometry.Transform>
C: <Rectangle.RenderTransform> <SkewTransform CenterX=”25″ CenterY=”25″
AngleX=”0″ AngleY=”45″ /></Rectangle.RenderTransform>
D: <Rectangle.RenderTransform> <ScaleTransform CenterX=”0″ CenterY=”0″
ScaleX=”45″ ScaleY=”45″ /></Rectangle.RenderTransform>
Correct Answers: B
10.You are creating a Windows Presentation Foundation application by using
Microsoft .NET Framework 3.5.
The application contains a CheckBox control named checkBox1 and a TextBox
control named t1.
The application contains the following code segment.
Public Class CheckBoxToColorConverter
Implements System.Windows.Data.IValueConverter
Public Function Convert(ByVal valueIn As Object, _
ByVal targetType As System.Type, ByVal parameter As Object, _
ByVal culture As System.Globalization.CultureInfo) As Object _
Implements System.Windows.Data.IValueConverter.Convert
Dim isChecked As Boolean = Convert.ToBoolean(valueIn)
Select Case isChecked
Case True
Return “Green”
Case Else
Exit Select
End Select
Return “Red”
End Function
End Class
You write the following code fragment.
01 <Window.Resources>
02 <src:CheckBoxToColorConverterKey=”checkBoxToColorConverter”/>
03 <Style x:Key=”CheckBoxChecked”>
04 <Setter Property=”Control.Template”
05 Value=”checkBoxToColorConverter” ></Setter>
06 </Style>
07 </Window.Resources>
08 <StackPanel>
09
10 <CheckBox Name=”checkBox1″>Check For Green</CheckBox>
11 </StackPanel>
You need to ensure that when checkBox1 is in the selected state, the
background of t1 changes to red.
Which code segment should you insert at line 09?
A:<TextBox Text=”TextBox”x:Name=”t1″ Background=”{Binding Path=IsChecked,
ElementName=TextBox, Mode=Default, Converter= {StaticResource
checkBoxToColorConverter}}”/>
B:<TextBox Text=”TextBox”x:Name=”t1″ Background=”{Binding Path=IsChecked,
ElementName=checkBox1, Mode=Default, Converter= {StaticResource
checkBoxToColorConverter}}”/>
C:<StackPanel> <TextBox Text=”TextBox” x:Name=”t1″ Background=”{Binding
ElementName=checkBox1}”/> <CheckBox Name=”checkBox1″>Check For
Green</CheckBox></StackPanel>
D:<TextBox Text=”TextBox” x:Name=”t1″ Background=”{Binding Path=IsChecked,
ElementName=checkBox1, Mode=Default, Converter={StaticResource
CheckBoxChecked}}”/>
Correct Answers: B