ResourceDictionary中的样式Xaml标签

时间:2014-03-04 08:36:17

标签: silverlight xaml silverlight-5.0 blend

我试图在Silverlight / XAML / C#中为标签控件定义样式。

我是新手,请原谅我的无知。

当我编写下面的代码时,IDE说theat Label 在silverlight项目中支持

那么如何为此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>

1 个答案:

答案 0 :(得分:1)

这是因为你没有引用sdk名称空间。

包括这个:

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

在资源词典的顶部,然后做一个干净的&amp;重建,它应该工作