Silverlight: Invalid Attribute Type for TargetType=“{x:Type TextBlock}”?

Silverlight does not support implicit styling via generic Styles (i.e. With a TargetType but without a static resource key - x:Key="") but WPF does.

Silverlight does not support implicit styling via generic Styles (i.e. With a TargetType but without a static resource key - x:Key="") but WPF does. You need to explicitly apply Styles using StaticResource references on each instance of your element that you want styled using Style="{StaticResource stylename}".

The Silverlight toolkit has an Implicit Style Manager (ISM) that gets around this by wrapping Silverlight markup and applying styles from ResourceDictionaries by parsing the content.

Value of TargetType change to TextBlock only. It should work. Optionally, give it x:Key and the value of this attribute use in your TextBlock as StaticResource....

1 When I do this I don't get an error but the style isn't applied to any of the textblocks in the usercontrol. – Spencer Ruport Mar 20 '09 at 18:32 1 Give it x:Key attribute and use it in your TextBlock control. I added a sample code to my answer.

– CZFox Mar 20 '09 at 18:40 1 Yeah that works but I'd prefer to not have to do it that way. :( – Spencer Ruport Mar 20 '09 at 18:59 Still not sure what the issue is. Oh well.

– Spencer Ruport Mar 20 '09 at 21:08.

Since what you are trying to do is implicit styling, so far Gordon's answer seems the right one: "Silverlight does not support implicit styling via generic Styles (i.e. With a TargetType but without a static resource key - x:Key="") but WPF does. " However implicit styles will work with Silverlight 4.

See silverlightshow.net/items/Implicit-Style....

Hmm, the following should work and cascade to all textblocks in the usercontrol element. Edit: Is NIRC. Page the correct codebehind for the usercontrol?

I wish I knew what was wrong, the following works perfect for me in a user control. Result is red text with a margin of 10px on all sides.

Edited my post in response to this. – Spencer Ruport Mar 20 '09 at 18:58.

Yeah, Silverlight 4 lets you do implicit styles now, you just need to do what Quinton says and just set the TargetType without a key, and you're good to go. Put it in the App. Xaml and it should propogate the style to all controls in the app.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions