locked
How can I edit a property of my class in a Custom Control by Expression Blend? RRS feed

  • Question

  • I have a Custom Control A,which has a property myB of Class B and a property myBList of List<B>.
    Here is partial code:

    public class B
    {
        ....
        public int TestValue
        {
            get{....}
            set{....}
        }
        .......
    }

    public class A : UserControl
    {
        .......
        public int OtherValue   // Blend can edit this property
        {
            get{....}
            set{....}
        }


        public B myB             //  Blend cann`t edit this property
        {
            get{....}
            set{....}
        }

        public List<B> myBList    // Blend can edit this property , and can edit it`s TestValue property
        {
            get{....}
            set{....}
        }
        .......
    }

    Here is question:
    1)Expression Blend can edit myBList,but cann`t edit myB,how can I edit myB by Expression Blend?
    2)How can I edit TestValue property by ListBox or other control,because TestValue can only be assigned by 1,2 or 3 in my code.
    3)Are there some Attributes can I use to TestValue property,with which Blend can deal?

    • Edited by yangjunzhu Sunday, June 8, 2008 5:36 AM code
    Sunday, June 8, 2008 5:28 AM

All replies

  • Howdy,
     
    You are using CLR property syntax here... you need to be using dependency properties

    http://msdn.microsoft.com/en-us/library/ms752914.aspx

    For quick properties that you dont need the full wieght of Dependency Properties, you can use an automatic property syntax

    public B myB { get; set; }

    Cheers


    Learn Expression Blend at learnexpressionstudio.com -- my blog : http://x-coders.com/blogs/sneaky/default.aspx
    Monday, June 9, 2008 6:30 AM
    Moderator
  • First Thanks!
    I think that I don`t need to be using dependency properties,because  OtherValue and myBList  are not dependency properties, but they can be edited by Blend.
    Monday, June 9, 2008 9:44 AM
  • It being able to edit an Int property is fine. Not being able to edit the property with your custom type, may mean that Blend doesn't know how UI to show for editing the type. Some suggestions that you may want to try

    In your class B, mark TestValue as the default property value. And you may want to see if implementing a custom property editor will help - http://msdn.microsoft.com/en-us/library/bb892994.aspx
    MVP Client App
    Tuesday, June 10, 2008 8:33 AM