- stepan.fiala
- Posts: 5
- Joined:
Value cannot be assigned to the property (property has type 'Noesis.Effect', value has type 'DropShadowEffect')
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?
-
sfernandez
Site Admin
- Posts: 2997
- Joined:
Re: Value cannot be assigned to the property (property has type 'Noesis.Effect', value has type 'DropShadowEffect')
I guess this is with Noesis 3.0.12, right? This looks like a bug we solved for the upcoming 3.1 version.
Until you upgrade there is a workaround, you can define the property of type object:
Until you upgrade there is a workaround, you can define the property of type object:
Code: Select all
public static readonly DependencyProperty ContentEffectProperty = DependencyProperty.Register(
"ContentEffect", typeof(object), typeof(CustomControl), new PropertyMetadata(null));
- stepan.fiala
- Posts: 5
- Joined:
Re: Value cannot be assigned to the property (property has type 'Noesis.Effect', value has type 'DropShadowEffect')
Works! Thanks a lot for your help.
Who is online
Users browsing this forum: Google [Bot] and 11 guests