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?