Value cannot be assigned to the property (property has type 'Noesis.Effect', value has type 'DropShadowEffect')
Posted: 16 Jul 2021, 11:27
I'm trying to create a custom control with a ContentEffect property.
It should be a stylable property that applies an effect on the ContentPresenter:
This is how the property is used:
It works fine in WPF, however in Unity, it throws the following errors:
[noesis] Invalid value 'DropShadowEffect' for property 'Project.ButtonWithImage.ContentEffect' in Setter
[noesis] Value cannot be assigned to the property 'Project.ButtonWithImage.ContentEffect' (property has type 'Noesis.Effect', value has type 'DropShadowEffect')
I've tried to use type aliases (as described here) but it did not help.
Any ideas?
Code: Select all
public static readonly DependencyProperty ContentEffectProperty = DependencyProperty.Register("ContentEffect", typeof(Effect), typeof(ButtonWithImage), new PropertyMetadata(null));
public Effect ContentEffect
{
get { return (Effect)GetValue(ContentEffectProperty); }
set { SetValue(ContentEffectProperty, value); }
}
Code: Select all
<ContentPresenter x:Name="Text" HorizontalAlignment="Center" VerticalAlignment="Center" Effect="{Binding Path=ContentEffect, RelativeSource={RelativeSource Mode=TemplatedParent}}" />
Code: Select all
<Setter Property="ContentEffect">
<Setter.Value>
<DropShadowEffect BlurRadius="5"/>
</Setter.Value>
</Setter>
[noesis] Invalid value 'DropShadowEffect' for property 'Project.ButtonWithImage.ContentEffect' in Setter
[noesis] Value cannot be assigned to the property 'Project.ButtonWithImage.ContentEffect' (property has type 'Noesis.Effect', value has type 'DropShadowEffect')
I've tried to use type aliases (as described here) but it did not help.
Any ideas?