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

Issue with databinding in animations for ContentControl/ItemsControl

10 Jul 2020, 10:03

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.
 
User avatar
sfernandez
Site Admin
Posts: 1915
Joined: 22 Dec 2011, 19:20

Re: Issue with databinding in animations for ContentControl/ItemsControl

10 Jul 2020, 11:44

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>
 
ck_russ
Topic Author
Posts: 27
Joined: 20 May 2020, 14:41

Re: Issue with databinding in animations for ContentControl/ItemsControl

10 Jul 2020, 11:56

Reported here: https://www.noesisengine.com/bugs/view.php?id=1754

Thanks for the clean work around!

Who is online

Users browsing this forum: No registered users and 1 guest