views:

49

answers:

2

I have a custom control in Silverlight, the change of property via property window is not getting updated until I build the application once again. What could be the problem?

Say for example. I have a control called Shapes. If I select type of the shape as "Octane" it should show a sample octane in blend design-time surface.

But, in my case it is not happening, the blend designer is not getting updated untill I build the application again. Please advice me on this. I don't want to put the consumer in trouble by letting them build it for every change in property value they make.

Note: All the exposed properties in the control are dependency property.

+1  A: 

Have you implemented the setter of your property so that the controls update when the property's value is changed?

(BTW, just because I'm curious, what's an octane shape? does it have something to do with chemistry?)

vc 74
vc74, yeah I'm using dp. The problem is the property change is not getting updated even to the setter of the dp, property changed callback is not getting triggered. But, when I build the app (Ctrl+Shift+B) it is getting updated and applied.
Avatar
Additional Note: Also, OnPropertyChanged overridden method is not available in silverlight, so I'm unable to manual layout updation as well :(
Avatar
Yeah. It is about chemistry. Thanks for the help. Though it doesn't solve the issue, it helped me to look over again and again setters to help reduce the issue. So, assigning you the bounty. :)
Avatar
Thanks; glad I could help
vc 74
A: 

What I had was a Properties of type CommonStyles for applying styles. For example,

CommonStyles will contains dp's like Background, Foreground, Thickness, etc.,

The mistake I done was, I directly assigned the values like below. In base class. [ShapeStyle is a dp of type CommonStyle]

//// Both properties are dp's but, assigned them like normal property. This caused the issue
ShapeBase.Background = this.Shape.ShapeStyle.Background;
ShapeBase.Foreground = this.Shape.ShapeStyle.Foreground; 

ShapeFace.Background = this.Shape.ShapeFaceStyle.Background;
...

When, I change the background property it won't update my ShapeBase.Background property. Since, it is not dependency bound.

I resolved it by, dp binding. Like below.

this.ShapeBase.SetBinding(BackgroundProperty, 
              new Binding() { 
              Source = this.Shape.ShapeStyle,
              Path = new PropertyPath("Background") });
Avatar