This is a migrated thread and some comments may be shown as answers.

PropertyGrid does not update nested properties properly

1 Answer 60 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
Jürgen
Top achievements
Rank 1
Jürgen asked on 17 Jun 2014, 08:49 AM

Hi,
I want to show the properties of an nested object a runtime. I defined a enumeration on which the object is created.

01.namespace RadGridView_SL4_AR_12
02.{
03.    /// <summary>
04.    /// A football position.
05.    /// </summary>
06.    public enum Position
07.    {
08.        GK, // create a GKPositionBehaviour
09.        DF, // create a DFPositionBehaviour
10.        MF, // create a MFPositionBehaviour
11.        FW  // create a FWPositionBehaviour
12.    }
13.     
14.    public class GKPositionBehaviour
15.    {
16.        public int A { get; set; }
17.    }
18. 
19.    public class DFPositionBehaviour
20.    {
21.        public int B { get; set; }
22.    }
23. 
24.    public class MFPositionBehaviour
25.    {
26.        public int C { get; set; }
27.    }
28. 
29.    public class FWPositionBehaviour
30.    {
31.        public int D { get; set; }
32.    }
33. 
34.}

Here is my viewmodel which does the instantiation of of the object.
01.namespace RadPropertyGridTester
02.{
03.    public class MyViewModel : INotifyPropertyChanged
04.    {
05.   
06.        private Position position = Position.DF;
07.        public Position Position
08.        {
09.            get
10.            {
11.                return position;
12.            }
13.             
14.            set
15.            {
16.                position = value;
17.                switch (position)
18.                {
19.                    case Position.DF:
20.                    Behavior = new DFPositionBehaviour();
21.                        break;
22.                    case Position.GK:
23.                    Behavior = new GKPositionBehaviour();
24.                        break;
25.                    case Position.MF:
26.                        Behavior = new MFPositionBehaviour();
27.                        break;
28.                    case Position.FW:
29.                        Behavior = new FWPositionBehaviour();
30.                        break;
31.                }
32.                 
33.                OnPropertyChanged("Position");
34.            }
35.        }
36. 
37.        private Object behavior = new DFPositionBehaviour();
38.        public Object Behavior
39.        {
40.            get
41.            {
42.                return behavior;
43.            }
44. 
45.            set
46.            {
47.                behavior = value;
48.                OnPropertyChanged("Behavior");
49.            }
50.        }
51.        // abbreviated for clarity
52.     }
53.}

When I start the program, the initial look is as expected, but when I change the property in the "Position" combo box, the property name of my Behavior object is not updated at all.
After changing to Position GK the value for the property name is supposed to be "A" and not "B".
How do i work around this bug?

 

1 Answer, 1 is accepted

Sort by
0
Yoan
Telerik team
answered on 20 Jun 2014, 09:13 AM
Hi J├╝rgen

I noticed that a colleague of mine has posted an answer to the same question in the other support thread you have opened. In order to achieve a fruitful and consistent dialogue, I would ask you to carry out any further communication there. Thank you.

Regards,
Yoan
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
PropertyGrid
Asked by
Jürgen
Top achievements
Rank 1
Answers by
Yoan
Telerik team
Share this question
or