2009-05-20 9 views
0

次のコードでこのエラーが発生する理由は何ですか? Silverlight 3でカスタムコントロールの既定のテンプレートを作成しようとしています。SilverlightカスタムコントロールのプロパティTargetTypeの無効な属性値

II無効な属性値のカスタム:プロパティTargetTypeのCaptionControl。 [Line:5 Position: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> 

using System.Windows; 
    using System.Windows.Controls; 

    namespace Controls.Silverlight 
    { 
     public class CaptionControl : ContentControl 
     { 
      public CaptionControl() 
      { 
       this.DefaultStyleKey = typeof(CaptionControl); 
      } 

      public double CaptionWidth 
      { 
       get { return (double)GetValue(CaptionWidthProperty); } 
       set { SetValue(CaptionWidthProperty, value); } 
      } 

      // Using a DependencyProperty as the backing store for CaptionWidth. This enables animation, styling, binding, etc... 
      public static readonly DependencyProperty CaptionWidthProperty = 
       DependencyProperty.Register("CaptionWidth", typeof(double), typeof(CaptionControl), null); 


      public string Caption 
      { 
       get { return (string)GetValue(CaptionProperty); } 
       set { SetValue(CaptionProperty, value); } 
      } 

      // Using a DependencyProperty as the backing store for Caption. This enables animation, styling, binding, etc... 
      public static readonly DependencyProperty CaptionProperty = 
       DependencyProperty.Register("Caption", typeof(string), typeof(CaptionControl), null); 


     } 
    } 

II無効な属性値のカスタム:プロパティTargetTypeのCaptionControl。 [行:5位置:23]

答えて

0

問題が見つかりました。 Visual Studioがどうにかして自動的にApp.xamlに次のコードを入力し、コードを修正して問題を解決したと思います。

<ResourceDictionary.MergedDictionaries> 
    <ResourceDictionary Source="/Controls.Silverlight;Component/themes/generic.xaml"/> 
</ResourceDictionary.MergedDictionaries> 
+0

テーマに問題がありましたか?それが何だった? – VoodooChild

+0

いいえ、問題は、私がgeneric.xamlをapp.xamlファイルに含めることでした。 generic.xamlはデフォルトでインクルードされるため、app.xamlには入れないでください。 – NotDan

関連する問題