OverMalo
Topic Author
Posts: 5
Joined: 08 Feb 2012, 11:05

Animation problem with binding a resource

23 Feb 2012, 09:13

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

Re: Animation problem with binding a resource

23 Feb 2012, 14:21

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>
 
OverMalo
Topic Author
Posts: 5
Joined: 08 Feb 2012, 11:05

Re: Animation problem with binding a resource

23 Feb 2012, 15:42

Hi,

Thanks!
 
User avatar
sfernandez
Site Admin
Posts: 1912
Joined: 22 Dec 2011, 19:20

Re: Animation problem with binding a resource

24 Feb 2012, 15:24

The problem discussed in this topic was fixed in v0.9.1.

Who is online

Users browsing this forum: Google [Bot] and 1 guest