<p>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 <em>have</em> to be DPs because I want to be able to animate them.)</p>

<p>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.</p>

<p>Anyone else come across this?</p>

<p>edit:</p>

<p>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:</p>

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

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

    /// &lt;summary&gt;
    /// ScaleXProperty property changed handler. 
    /// &lt;/summary&gt;
    /// &lt;param name="d"&gt;MyPanel that changed its ScaleX.&lt;/param&gt;
    /// &lt;param name="e"&gt;DependencyPropertyChangedEventArgs.&lt;/param&gt; 
    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);
    }
</code></pre>

<p>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.</p>

[{'answer_id': 72058, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 0, 'selected': False, 'text': '<p>I would try commenting out the InvalidateArrange in the OnPropertyChanged and see what happens.</p>\n'}, {'answer_id': 86917, 'author': 'Arun', 'author_id': 16671, 'author_profile': 'https://Stackoverflow.com/users/16671', 'pm_score': 2, 'selected': True, 'text': "<p>It's a documented bug with Silverlight 2 Beta 2. You can't animate two custom dependancy properties on the same object.</p>\n"}, {'answer_id': 140824, 'author': 'Jim Lynn', 'author_id': 6483, 'author_profile': 'https://Stackoverflow.com/users/6483', 'pm_score': 0, 'selected': False, 'text': "<p>I hope it's not bad form to answer my own question.</p>\n\n<p>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.</p>\n\n<p>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.</p>\n"}]
['https://Stackoverflow.com/questions/62382', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/6483/']