Page 1 of 1

Issue with databinding in animations for ContentControl/ItemsControl

Posted: 10 Jul 2020, 10:03
by ck_russ
There is some sort of issue with databinding for animations inside of ContentControl/ItemsControl. The following (xamltoy ready) example creates a Rectangle and animates its Fill, which has an initial value of pink. It should animate between Green and Blue, with the Blue coming from databinding. In Blend this is what happens. In Noesis instead it animates from Green to Pink because the databinding fails:
<Grid
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

  <ContentControl>
    <ContentControl.Content>
      <Color>#ff0000ff</Color>
    </ContentControl.Content>
    <ContentControl.ContentTemplate>
      <DataTemplate>
        <Grid>
          <Rectangle Name="SomeRect" Width="200" Height="200" Fill="Pink">
            <Rectangle.Triggers>
              <EventTrigger RoutedEvent="Rectangle.Loaded">
                <EventTrigger.Actions>
                  <BeginStoryboard>
                    <Storyboard>
                      <ColorAnimation 
                                      Duration="0:0:5" 
                                      From="Green"
                                      To="{Binding}"
                                      AutoReverse="True" RepeatBehavior="Forever"
                                      Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)"
                                      Storyboard.TargetName="SomeRect">
                      </ColorAnimation>
                    </Storyboard>
                  </BeginStoryboard>
                </EventTrigger.Actions>
              </EventTrigger>
            </Rectangle.Triggers>
          </Rectangle>
        </Grid>
      </DataTemplate>
    </ContentControl.ContentTemplate>
  </ContentControl>
</Grid>
Noesis itself does not report any errors/warnings in the outputted log.

Re: Issue with databinding in animations for ContentControl/ItemsControl

Posted: 10 Jul 2020, 11:44
by sfernandez
It is a bug, it seems bindings inside Triggers defined in a template element are not working, could you please report this in our bugtracker?

In the meantime you can use interactivity triggers instead, I verified they work in that case:
<Grid
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
  xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions">
  <ContentControl>
    <ContentControl.Content>
      <Color>#ff0000ff</Color>
    </ContentControl.Content>
    <ContentControl.ContentTemplate>
      <DataTemplate>
        <Rectangle Name="SomeRect" Width="200" Height="200" Fill="Pink">
          <i:Interaction.Triggers>
            <i:EventTrigger EventName="Loaded">
              <ei:ControlStoryboardAction>
                <ei:ControlStoryboardAction.Storyboard>
                  <Storyboard>
                    <ColorAnimation Duration="0:0:2" From="Green" To="{Binding}" AutoReverse="True" RepeatBehavior="Forever"
                                    Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)"
                                    Storyboard.TargetName="SomeRect">
                    </ColorAnimation>
                  </Storyboard>
                </ei:ControlStoryboardAction.Storyboard>
              </ei:ControlStoryboardAction>
            </i:EventTrigger>
          </i:Interaction.Triggers>
        </Rectangle>
      </DataTemplate>
    </ContentControl.ContentTemplate>
  </ContentControl>
</Grid>

Re: Issue with databinding in animations for ContentControl/ItemsControl

Posted: 10 Jul 2020, 11:56
by ck_russ
Reported here: https://www.noesisengine.com/bugs/view.php?id=1754

Thanks for the clean work around!