PrepAway - Latest Free Exam Questions & Answers

Which code fragment should you use?

You use Microsoft .NET Framework 4 to create a Windows Presentation Foundation (WPF) application.
The application contains the following code fragment.
<StackPanel> <TextBlock Style=”{StaticResource MyStyle}”>Hello World</TextBlock>
<Button Style=”{StaticResource MyStyle}”>Ok</Button>
</StackPanel>
You need to define a style that applies the following properties to the text in the StackPanel object:
* FontSize = 32
* FontWeight = Bold
Which code fragment should you use?

PrepAway - Latest Free Exam Questions & Answers

A.
<Style x:Key=”MyStyle” TargetType=”{x:Type Control}”>
<Setter Property=”TextElement.FontSize” Value=”32″ />
<Setter Property=”TextElement.FontWeight” Value=”Bold” />
</Style>

B.
<Style x:Key=”MyStyle” TargetType=”{x:Type FrameworkElement}”>
<Setter Property=”TextElement.FontSize” Value=”32″ />
<Setter Property=”TextElement.FontWeight” Value=”Bold” />
</Style>

C.
<Style x:Key=”MyStyle” TargetType=”{x:Type TextElement}”>
<Setter Property=”Control.FontSize” Value=”32″ />
<Setter Property=”Control.FontWeight” Value=”Bold” />
</Style>

D.
<Style x:Key=”MyStyle” TargetType=”{x:Type UserControl}”>
<Setter Property=”Control.FontSize” Value=”32″ />
<Setter Property=”Control.FontWeight” Value=”Bold” />
</Style>


Leave a Reply