You are employed as an application developer at ABC.com. You make use of Microsoft .NET
Framework 4 to develop Windows Presentation Foundation (WPF) applications.
You have developed a new application, named ABCApp21. You then receive instructions to make
use of the StackPanel layout. You have also been informed that the StackPanel layout should
contain two Button controls. Both of these Button controls must be able to display the word “Save”
in a TextBox.
Which of the following actions should you take?
A.
You should consider writing the code shown below:
<StackPanel>
<StackPanel.Resources>
<ControlTemplate
TargetType=”{x:Type Button}”
B.
Key=”btn”>
<RealBlock Text=”{Binding}” />
</ControlTemplate>
</StackPanel.Resources>
<Button Content=”Save”
Template=”{StaticResource btn}” />
<Button Template=”{DynamicResource btn}”>
<TextBlock Text=”Save” />
</Button>
</StackPanel>
C.
You should consider writing the code shown below:
<StackPanel>
<StackPanel.Resources>
<ControlTemplate
TargetType=”{x:Type Button}”
D.
Key=”btn”>
<ListBox Text=”{TemplateBinding Content}” />
</ControlTemplate>
</StackPanel.Resources>
<Button Content=”Save”
Template=”{StaticResource btn}” />
<Button Template=”{StaticResource btn}”>
<ListBox Text=”Save” />
</Button>
</StackPanel>
E.
You should consider writing the code shown below:
<StackPanel>
<StackPanel.Resources>
<ControlTemplate
TargetType=”{x:Type Button}”
F.
Key=”btn”>
<Presenter Content=”{Binding}”
</ControlTemplate>
</StackPanel.Resources>
<Button Content=”Save”
Template=”{StaticResource btn}” />
<Button Template=”{DynamicResource btn}”>
<Text=”Save” />
</Button>
</StackPanel>
G.
You should consider writing the code shown below:
<StackPanel>
<StackPanel.Resources>
<ControlTemplate
TargetType=”{x:Type Button}”
H.
Key=”btn”>
<ContentPresenter />
</ControlTemplate>
</StackPanel.Resources>
<Button Content=”Save”
Template=”{StaticResource btn}” />
<Button Template=”{StaticResource btn}”>
<TextBox Text=”Save” />
</Button>
</StackPanel>
Explanation: