0

Im trying to define a style for a label control in Silverlight/XAML/C#.

Im new to this so please excuse my ignorance.

When I wrote the below code the IDE said theat Label Supported in a silverlight project

So how do I define a style type for this Label ?

<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">


    ...
    <Style x:Key="TitleFontStyle" TargetType="sdk:Label"> 
        <Setter Property="Background" Value="{StaticResource ButtonBackgroundGradientBrush}" /> 

    </Style> 
</ResourceDictionary>
IEnumerable
  • 3,610
  • 14
  • 49
  • 78
  • I just noticed there is also a TextBlock ? whats the difference between Label and TextBlock ? – IEnumerable Mar 04 '14 at 08:38
  • 1
    [difference between `Label` and `TextBlock` (WPF)](http://joshsmithonwpf.wordpress.com/2007/07/04/differences-between-label-and-textblock/). I think [you can safely use `TextBlock` instead of label](http://stackoverflow.com/a/2429470/2998271) – har07 Mar 04 '14 at 09:49
  • True Im now using TextBlock. Almost pointless to have both. – IEnumerable Mar 04 '14 at 21:24
  • Actually I found this post http://stackoverflow.com/questions/5382925/difference-between-label-and-textblock-wpf – IEnumerable Mar 04 '14 at 21:25

1 Answers1

1

It's because you dont have the sdk namespace referenced.

Include this:

xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"

at the top of your resource dictionary, then do a clean & rebuild and it should work

DNKROZ
  • 2,634
  • 4
  • 25
  • 43