What is the difference between:
<Style TargetType="{x:Type Border}">
and:
<Style TargetType="Border">
When and why do I need to use the {x:Type …} ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There is no difference in effect; in both cases the TargetType property will be set to
typeof(Border)The first version
{x:Type Border}was needed in the first version of WPF because the compiler did not use theTypeConverterclass to convert the string into a Type object and you needed to specify theTypeExtensionclass to do that for you.The second version was introduced, if I remember correctly, with Silverlight and quickly found its way to the WPF compiler.
EDIT
My assumption on the
TypeConverterclass was wrong; this is implemented by theFrameworkElementFactory:From the documentation: