Issue with databinding in animations for ContentControl/ItemsControl
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:
Noesis itself does not report any errors/warnings in the outputted log.
Code: Select all
<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>
-
-
sfernandez
Site Admin
- Posts: 2061
- Joined:
Re: Issue with databinding in animations for ContentControl/ItemsControl
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:
In the meantime you can use interactivity triggers instead, I verified they work in that case:
Code: Select all
<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>
Who is online
Users browsing this forum: sfernandez and 2 guests