Which code segment should you use?

You are creating a Windows Presentation Foundation application by using Microsoft .NET Framework 3.5.
You use a template for button controls. The template is defined as a resource on the page that contains the button controls. The template has a key named tpCancel. You plan to add a button named Cancel to the user interface of the application. You need to ensure that the Cancel button uses the template.
Which code segment should you use?

You are creating a Windows Presentation Foundation application by using Microsoft .NET Framework 3.5.
You use a template for button controls. The template is defined as a resource on the page that contains the button controls. The template has a key named tpCancel. You plan to add a button named Cancel to the user interface of the application. You need to ensure that the Cancel button uses the template.
Which code segment should you use?

A.
<Button Template="tpCancel">Cancel</Button>

B.
<Button Template="{StaticResource tpCancel}">Cancel</Button>

C.
<Button>
<Button.Template>
<ControlTemplate x:Name="tpCancel" />
</Button.Template>
Cancel
</Button>

D.
<Button>
<Button.Template>
<ControlTemplate Resources="tpCancel" />
</Button.Template>
Cancel
</Button>



Leave a Reply 0

Your email address will not be published. Required fields are marked *