0
다음 코드로이 오류가 발생하는 이유는 무엇입니까? Silverlight 3에서 사용자 지정 컨트롤의 기본 템플릿을 만들려고합니다.Silverlight의 TargetType 속성에 대한 특성 값이 잘못되었습니다. 사용자 지정 컨트롤
II 속성 값이 Custom : CaptionControl 인 경우 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>
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);
}
}
잘못된 특성 값 사용자 지정 : Custom 속성 : TargetType의 CaptionControl. [줄 : 5 위치 : 23]
그래서 테마에 문제가 있습니까? 그게 뭐야? – VoodooChild
아니요, 문제는 app.xaml 파일에 generic.xaml을 포함시키고 있다는 것이 었습니다. generic.xaml은 기본적으로 포함되므로 app.xaml에 들어갈 수 없습니다. – NotDan