0

I might be missing something really obvious. I'm trying to write a custom Panel where the contents are laid out according to a couple of dependency properties (I'm assuming they have to be DPs because I want to be able to animate them.)

However, when I try to run a storyboard to animate both of these properties, Silverlight throws a Catastophic Error. But if I try to animate just one of them, it works fine. And if I try to animate one of my properties and a 'built-in' property (like Opacity) it also works. But if I try to animate both my custom properties I get the Catastrophic error.

Anyone else come across this?

edit:

The two DPs are ScaleX and ScaleY - both doubles. They scale the X and Y position of children in the panel. Here's how one of them is defined:

    public double ScaleX
    {
        get { return (double)GetValue(ScaleXProperty); }
        set { SetValue(ScaleXProperty, value); }
    }

    /// <summary> 
    /// Identifies the ScaleX dependency property.
    /// </summary> 
    public static readonly DependencyProperty ScaleXProperty =
                DependencyProperty.Register(
                      "ScaleX",
                      typeof(double),
                      typeof(MyPanel),
                      new PropertyMetadata(OnScaleXPropertyChanged));

    /// <summary>
    /// ScaleXProperty property changed handler. 
    /// </summary>
    /// <param name="d">MyPanel that changed its ScaleX.</param>
    /// <param name="e">DependencyPropertyChangedEventArgs.</param> 
    private static void OnScaleXPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
    {
        MyPanel _MyPanel = d as MyPanel;
        if (_MyPanel != null)
        {
            _MyPanel.InvalidateArrange(); 
        }
    }

    public static void SetScaleX(DependencyObject obj, double val)
    {
        obj.SetValue(ScaleXProperty, val);
    }

    public static double GetScaleX(DependencyObject obj)
    {
        return (double)obj.GetValue(ScaleXProperty);
    }

Edit: I've tried it with and without the call to InvalidateArrange (which is absolutely necessary in any case) and the result is the same. The event handler doesn't even get called before the Catastrophic error kicks off.

3 Answers 3

1

It's a documented bug with Silverlight 2 Beta 2. You can't animate two custom dependancy properties on the same object.

0

I would try commenting out the InvalidateArrange in the OnPropertyChanged and see what happens.

0

I hope it's not bad form to answer my own question.

Silverlight 2 Release Candidate 0 was released today, I've tested this problem on it, and it appears to have been fixed. Both Custom DPs in my test panel can now be animated properly, so the app is behaving as expected. Which is nice.

Note that this RC is only a developer-based RC so the standard build of Silverlight hasn't been updated. I'd expect it to be fully released in the next month, though.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.