ck_russ
Topic Author
Posts: 22
Joined: 20 May 2020, 14:41

Unable to set Color in XAML in Noesis: "Can't assign property to abstract class 'Color'."

09 Jul 2020, 11:17

This issue emerged in trying to figure out a hopefully related animation issue with colors. Noesis throws 'can't assign' errors and fails to render the following XAML:
    <Rectangle>
        <Rectangle.Fill>
            <SolidColorBrush>
                <SolidColorBrush.Color>
                    <Color A="255" R="255" G="0" B="0"/>
                </SolidColorBrush.Color>
            </SolidColorBrush>
        </Rectangle.Fill>
    </Rectangle>
----

The above is what I'm reporting. Below is the issue I'm trying to resolve but I haven't yet managed to create a simple example to replicate whatever the issue is. If anybody has any suggestions, it'd be much appreciated! The following is part of the template for an ItemsControl that displays a series of rectangles. It's an animation to give visual feedback to the user on where their mouse is:
                                <Rectangle x:Name="EffectRectangle" Fill="Green" Visibility="{Binding IsMouseOver, Converter={StaticResource Converters.BoolToVisibility}}" IsHitTestVisible="False">
                                    <Rectangle.Triggers>
                                        <EventTrigger RoutedEvent="Window.Loaded">
                                            <EventTrigger.Actions>
                                                <BeginStoryboard>
                                                    <Storyboard>
                                                        <ColorAnimation 
                                                            Duration="{Binding ViewModel.SquareHighlightPeriod}" 
                                                            From="{Binding ViewModel.SquareHighlightStartColor}" 
                                                            To="{Binding ViewModel.SquareHighlightEndColor}" 
                                                            AutoReverse="True" RepeatBehavior="Forever"
                                                            Storyboard.TargetProperty="Fill.(SolidColorBrush.Color)" 
                                                            Storyboard.TargetName="EffectRectangle">
                                                        </ColorAnimation>
                                                    </Storyboard>
                                                </BeginStoryboard>
                                            </EventTrigger.Actions>
                                        </EventTrigger>
                                    </Rectangle.Triggers>
                                </Rectangle>
This works in Blend, but not in Noesis. Now the really strange thing is that it DOES work if I get rid of the databinding for the storyboard. If I just set literal values for duration/from/to - everything works perfectly. So this seems obviously to be an issue with my databinding. However, I've confirmed this is not the case in two ways: Firstly it works blend, but also in Noesis I can use the same databound values to do things such as change the rectangle's fill color and everything works as it should.

So I assumed perhaps this was because Noesis was having some issue using databinding in animations. However, this is also not the case. If you take the above snippet and stick it into an independent Noesis project it works 100% fine with the databinding. So at this point I simply have no clue what the issue could even possibly be.
 
User avatar
sfernandez
Site Admin
Posts: 1881
Joined: 22 Dec 2011, 19:20

Re: Unable to set Color in XAML in Noesis: "Can't assign property to abstract class 'Color'."

09 Jul 2020, 14:11

Noesis parser doesn't support specifying value types (as Color) like that in xaml, this is a bug we want to solve in future versions: #1752.

Right now you should use the color string directly:
    <Rectangle>
        <Rectangle.Fill>
            <SolidColorBrush Color="#FFFF0000"/>
        </Rectangle.Fill>
    </Rectangle>
This should be enough to make the animation work in Noesis.
 
ck_russ
Topic Author
Posts: 22
Joined: 20 May 2020, 14:41

Re: Unable to set Color in XAML in Noesis: "Can't assign property to abstract class 'Color'."

10 Jul 2020, 07:29

Great, appreciated as always. I'll create a new thread if I can manage to figure out why the secondary issue is not functioning properly.

Who is online

Users browsing this forum: No registered users and 4 guests