안녕하세요. Custom Control을 만들고 있는 중 바인딩은 잘 되고 있는데 바인딩 오류가 계속 발생해서 문의드립니다.
발생하는 오류는 다음과 같습니다.
대상 요소의 관리하는 FrameworkElement 또는 FrameworkContentElement를 찾을 수 없습니다.
해당 소스코드는 다음과 같습니다.
NuemorphismBase.xaml
<DropShadowEffect x:Key="FirstDropShadowEffect"
BlurRadius="{Binding FirstBlurRadius, RelativeSource={RelativeSource TemplatedParent}}"
ShadowDepth="{Binding FirstShadowDepth, RelativeSource={RelativeSource TemplatedParent}}"
Direction="{Binding FirstDirection, RelativeSource={RelativeSource TemplatedParent}}"
Color="{Binding FirstBackgroundBrush, RelativeSource={RelativeSource TemplatedParent}}"/>
<DropShadowEffect x:Key="SecondeDropShadowEffect" BlurRadius="{Binding SecondBlurRadius, RelativeSource={RelativeSource TemplatedParent}}"
ShadowDepth="{Binding SecondShadowDepth, RelativeSource={RelativeSource TemplatedParent}}"
Direction="{Binding SecondDirection, RelativeSource={RelativeSource TemplatedParent}}"
Color="{Binding SecondBackgroundBrush, RelativeSource={RelativeSource TemplatedParent}}"/>
<Style TargetType="{x:Type ui:NuemorphismBase}">
<Setter Property="Background" Value="{StaticResource DefaultBackground}"/>
<Setter Property="Width" Value="100"/>
<Setter Property="Height" Value="100"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ui:NuemorphismBase}">
<Border x:Name="FirstBorder"
Background="{TemplateBinding Background}"
CornerRadius="{TemplateBinding FirstBorderCornerRadius}"
Effect="{StaticResource FirstDropShadowEffect}" >
<Grid x:Name="grid">
<Border x:Name="SecondBorder"
Background="{TemplateBinding Background}"
CornerRadius="{TemplateBinding SecondBorderCornerRadius}"
Effect="{StaticResource SecondeDropShadowEffect}">
</Border>
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
NuemorphismBase.cs (해당 클래스는 ContentControl을 상속받았습니다.)
public static CornerRadius DefaultFirstBorderCornerRadius = new CornerRadius(20);
public static readonly DependencyProperty FirstBorderCornerRadiusProperty =
DependencyProperty.Register(
"FirstBorderCornerRadius",
typeof(CornerRadius),
typeof(NuemorphismBase),
new PropertyMetadata(DefaultFirstBorderCornerRadius));
public CornerRadius FirstBorderCornerRadius
{
get => (CornerRadius)GetValue(FirstBorderCornerRadiusProperty);
set => SetValue(FirstBorderCornerRadiusProperty, value);
}
public static Color DefaultFirstBackgroundBrush = new Color() { A = 33, R = 0xD1, G = 0xD9, B = 0xE6 }; //"#33D1D9E6"
public static readonly DependencyProperty FirstBackgroundBrushProperty =
DependencyProperty.Register(
"FirstBackgroundBrush",
typeof(Color),
typeof(NuemorphismBase),
new PropertyMetadata(DefaultFirstBackgroundBrush));
public Color FirstBackgroundBrush
{
get => (Color)GetValue(FirstBackgroundBrushProperty);
set => SetValue(FirstBackgroundBrushProperty, value);
}
...
위의 이미지처럼 dependencyproperty로 설정한 모든 속성에서 오류가 발생합니다…
기능상에는 문제가 없지만 잘못된 방향으로 가니 오류가 발생하는 것으로 생각됩니다. 오류를 없앨 수 있는 방안이 있다면 도와주세요
감사합니다!