开发者

Getting AG_E_PARSER_BAD_PROPERTY_VALUE while data binding in WP7 User control

I have created a user control in Silverlight which bas开发者_运维技巧ically animates the size of a rectangle.

    <StackPanel x:Name="LayoutRoot" Background="Gray"><StackPanel.Resources>
        <Storyboard x:Name="myStoryboard" Completed="myStoryboard_Completed">
            <DoubleAnimation x:Name="ExpandY" From="{Binding Path=From}" To="{Binding Path=To}" Duration="00:00:2" 
            Storyboard.TargetName="myScaleTransform" 
            Storyboard.TargetProperty="ScaleY">
                <DoubleAnimation.EasingFunction>
                    <BackEase Amplitude="0.0" EasingMode="EaseInOut" />
                </DoubleAnimation.EasingFunction>
            </DoubleAnimation>
        </Storyboard>            
    </StackPanel.Resources>

    <Rectangle  x:Name="myRectangle" MouseLeftButtonDown="Mouse_Clicked" 
 Fill="{Binding Path=Barcolor}" Width="35" Height="50" RadiusX="2" RadiusY="2"  MouseEnter="myRectangle_MouseEnter" Stroke="White" StrokeThickness="0" MouseLeave="myRectangle_MouseLeave">
        <Rectangle.RenderTransform>
            <ScaleTransform x:Name="myScaleTransform" CenterY="50"/>
        </Rectangle.RenderTransform>
    </Rectangle>
</StackPanel>

I have bound an object which implements INotifyPropertyChanged to this as the data context.

Now, the whole thing works fine when I run it as a silverlight control in an ASP.NET host page. But when I port the same code to create a WP7 user control I get the AG_E_PARSER_BAD_PROPERTY_VALUE pointing to the location where From="{Binding Path=From}" is located in the Double animation "ExpandY".

Is there anything different how the data is bound in a silverlight control and a WP7 user control?


The problem here is that DoubleAnimation is not a FrameworkElement and in Silverlight for WP7 you can only set a binding on a FrameworkElement. In order to achieve this effect you'll need to manipulate the animation in code-behind, possibly by wrapping the behavior up into a separate UserControl.

Same as this question: Binding to 'To' In Storyboard


Based on your tags I'm assuming that you're using SL4 on the web version. WP7 is based on Silverlight 3 and doesn't support binding in exactly the same way.

I suspect your problem is due to the same as in Dynamically change gradientstop color

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜