What is the difference for
TargetType="{x:Type Button}"
and
TargetType="Button"
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.
The XAML designer applies inbuilt type converters that convert the string value “Button” to
System.Typewhich isButton, which makes it seem like there is no practical difference.However one should practise to use the explicit Type specification using
x:Type.Explicit
Typespecification is required is when we inheritStylesusingBasedOn, there implicit stringTypewont work.e.g.
This would work
But not this…
as here it would try to search a resource with Key “Button”. But in the
x:Typespecification, as we already specified explicitButtonTypethe search of the static resource would be happen for theStylewhich is targetted for aButton.