locked
Animate a Custom Property RRS feed

  • Question

  • Hello,

    I have a window with a couple added Dependency Properties. MySmall is a double. MyBig is of type Big and has it's own dependency property named Small (also a double).

    My question is how would I animate MySmall and Small? Binding to them is easy enough in Blend, but I can't figure out how to get access to them in a storyboard.

    Here's the code:
    ////////////////////////// MySmall ////////////////////
    public double MySmall
    {
        get { return (double)GetValue(MySmallProperty); }
        set { SetValue(MySmallProperty, value); }
    }
    public static readonly DependencyProperty MySmallProperty =
        DependencyProperty.Register(
            "MySmall",
            typeof(double),
            typeof(Window1),
            new PropertyMetadata(0.0));
    
    ////////////////////////// MyBig //////////////////////
    public Big MyBig
    {
        get { return (Big)GetValue(MyBigProperty); }
        set { SetValue(MyBigProperty, value); }
    }
    public static readonly DependencyProperty MyBigProperty =
        DependencyProperty.Register(
            "MyBig",
            typeof(Big),
            typeof(Window1),
            new PropertyMetadata(new Big()));
    
    ////////////////////////// Big Class ////////////////
    public class Big : DependencyObject
    {
        public double Small
        {
            get { return (double)GetValue(SmallProperty); }
            set { SetValue(SmallProperty, value); }
        }
        public static readonly DependencyProperty SmallProperty =
            DependencyProperty.Register(
                "Small",
                typeof(double),
                typeof(Big),
                new PropertyMetadata(0.0));
    }


    Thanks,
    Steve
    Tuesday, September 29, 2009 2:02 AM

All replies

  • Typo. MyBig should initialize to null or it craps out.
    The last line of Mybig should be: new PropertyMetadata( null ));

    I managed to make the animation programatically, but that defeats the purpose of using Blend. I've generally found the use of custom properties to be very frustrating and complicated in Blend. Version 3 has improved binding to custom properties, but even a task as basic as setting the custom property of a window is impossible. I'd love to see these issues improved in the next version :)


    -Steve
    Wednesday, September 30, 2009 12:37 AM