C# Silverlight自定义控件中属性TargetType的属性值无效

C# Silverlight自定义控件中属性TargetType的属性值无效,c#,.net,silverlight,silverlight-3.0,C#,.net,Silverlight,Silverlight 3.0,你知道我为什么用下面的代码得到这个错误吗?我正在尝试为Silverlight 3中的自定义控件创建默认模板 IInvalid属性值自定义:属性TargetType的CaptionControl。[第5行位置:23] <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006

你知道我为什么用下面的代码得到这个错误吗?我正在尝试为Silverlight 3中的自定义控件创建默认模板

IInvalid属性值自定义:属性TargetType的CaptionControl。[第5行位置:23]

<ResourceDictionary 
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:custom="clr-namespace:Controls.Silverlight">
    <Style TargetType="custom:CaptionControl">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="custom:CaptionControl">
                    <Grid x:Name="RootElement">

                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>

IInvalid属性值自定义:属性TargetType的CaptionControl。[行:5位置:23]

我发现了问题。我认为Visual Studio不知何故自动在我的App.xaml中输入了以下内容,将代码取出修复了问题

<ResourceDictionary 
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:custom="clr-namespace:Controls.Silverlight">
    <Style TargetType="custom:CaptionControl">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="custom:CaptionControl">
                    <Grid x:Name="RootElement">

                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
    <ResourceDictionary Source="/Controls.Silverlight;Component/themes/generic.xaml"/>
</ResourceDictionary.MergedDictionaries>


那么主题或..的问题是什么。。?是什么?不是,问题是我在app.xaml文件中包含了generic.xaml。默认情况下会包含generic.xaml,因此它不应该进入app.xaml。