Just play around with Silverlight a bit and try to style all text blocks. Next xaml:
<Style TargetType="{x:Type TextBlock}"> <Setter Property="Margin" Value="10, 10, 10, 10" /> </Style>
Gives me the error Invalid attribute value {x:Type TextBlock} for property TargetType.
I copied and pasted this bit from MSDN, so I lost a bit why I get this error.
EDIT:
Here is the complete code I'm trying now:
<UserControl x:Class="NIRC.Page" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Width="400" Height="300"> <UserControl.Resources> <Style TargetType="TextBlock"> <Setter Property="Margin" Value="10" /> <Setter Property="Foreground" Value="Red" /> </Style> </UserControl.Resources> <TextBlock>Hello World!</TextBlock> </UserControl>
Here's what it looks like:
alt text http://www.netortech.com/Content/slhw.jpg
Spencer ruport
source share