Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting Style TargetType in WPF

Tags:

c#

wpf

xaml

Is there a difference between these two ways of setting a style's TargetType?

<Style TargetType="Grid"></Style>

<Style TargetType="{x:Type Grid}"></Style>
like image 769
Patrick Y Avatar asked Apr 26 '26 13:04

Patrick Y


1 Answers

There is no difference. You are just explicitly adding the x:Type attribute. By default WPF parses it with {x:Type } that you added in TargetType

EDIT:

When you are using custom controls you want to explitly set the {x:Type CustomControl}

like image 153
123 456 789 0 Avatar answered Apr 29 '26 03:04

123 456 789 0



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!