+3  A: 

Value of TargetType change to TextBlock only. It should work.

<Style TargetType="TextBlock">
   <Setter Property="Margin" Value="10, 10, 10, 10" />
</Style>

Optionally, give it x:Key and the value of this attribute use in your TextBlock as StaticResource.

<Style x:Key="someStyleName" TargetType="TextBlock">
   <Setter Property="Margin" Value="10, 10, 10, 10" />
</Style>
...
<TextBlock x:Name="myTextBlock" Text="Silverlight" Style="{StaticResource someStyleName}"/>
CZFox
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
Give it x:Key attribute and use it in your TextBlock control. I added a sample code to my answer.
CZFox
Yeah that works but I'd prefer to not have to do it that way. :(
Spencer Ruport
Still not sure what the issue is. Oh well.
Spencer Ruport
A: 

Hmm, the following should work and cascade to all textblocks in the usercontrol element.

<UserControl>
    <UserControl.Resources>
     <Style TargetType="TextBlock">
      <Setter Property="Margin" Value="10" />
     </Style>
    </UserControl.Resources>
    <TextBlock Text="This has a margin of 10 on all sides!" />
</UserControl>

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.

<UserControl x:Class="..."
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Height="300" Width="300">
    <UserControl.Resources>
     <Style TargetType="TextBlock">
      <Setter Property="Margin" Value="10" />
      <Setter Property="Foreground" Value="Red" />
     </Style>
    </UserControl.Resources>
    <TextBlock>Hello World!</TextBlock>
</UserControl>

Result is red text with a margin of 10px on all sides.

Quintin Robinson
Edited my post in response to this.
Spencer Ruport
+4  A: 

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.

Gordon Mackie JoanMiro
+1  A: 

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 http://www.silverlightshow.net/items/Implicit-Styles-in-Silverlight-4.aspx

Denis Dollfus