Page 1 of 1

Animation problem with binding a resource

Posted: 23 Feb 2012, 09:13
by OverMalo
Hi,

I am using NoesisGUI to develop 2D game and i have problem with binding a resource in DiscreteObjectKeyFrame.

This code works:
<DiscreteObjectKeyFrame KeyTime="0:0:0.08">
<DiscreteObjectKeyFrame.Value>
<ImageBrush ImageSource="images/chew_man_chew/rompetejas02.png"/>
</DiscreteObjectKeyFrame.Value>

But this code not works:
<UserControl.Resources>
<ImageBrush x:Key="ImgRompetejas02" ImageSource="images/chew_man_chew/rompetejas02.png"/>
</UserControl.Resources>
<DiscreteObjectKeyFrame KeyTime="0:0:0.08" Value="{StaticResource ImgRompetejas02}">

However I can use the resource "ImgRompetejas02" here:
<Border x:Name="ChewManChew" Width="128" Height="128" Background="{StaticResource ImgRompetejas02"}/>

Image
Image
In XamlPad it works both ways.

Thanks.

Re: Animation problem with binding a resource

Posted: 23 Feb 2012, 14:21
by sfernandez
I found the bug.

Meanwhile you can turn around the problem by defining the Storyboard in the root element Resources property, and refer to it from the BeginStoryboard action with a StaticResource:
<Grid
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Grid.Resources>
        <ImageBrush x:Key="ImgRompetejas02" ImageSource="images/chew_man_chew/rompetejas02.png"/>
        <Storyboard x:Key="AnimImg">
            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Fill">
                <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ImgRompetejas02}"/>
            </ObjectAnimationUsingKeyFrames>
        </Storyboard>
    </Grid.Resources>
    <Rectangle Fill="SkyBlue" Width="125" Height="125">
        <Rectangle.Triggers>
            <EventTrigger RoutedEvent="UIElement.MouseEnter">
                <EventTrigger.Actions>
                    <BeginStoryboard Storyboard="{StaticResource AnimImg}"/>
                </EventTrigger.Actions>
            </EventTrigger>
        </Rectangle.Triggers>
    </Rectangle>
</Grid>

Re: Animation problem with binding a resource

Posted: 23 Feb 2012, 15:42
by OverMalo
Hi,

Thanks!

Re: Animation problem with binding a resource

Posted: 24 Feb 2012, 15:24
by sfernandez
The problem discussed in this topic was fixed in v0.9.1.