When I set the value of IsClosed
during runtime, OnIsClosedChanged()
is called fine.
However, the Designer sets the value of the property but does not call the OnIsClosedChanged()
.
public static DependencyProperty IsClosedProperty = DependencyProperty.Register("IsClosed", typeof(bool), typeof(GroupBox), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));
public bool IsClosed {
get {
return (bool)this.GetValue(IsClosedProperty);
}
set {
if ((bool)this.GetValue(IsClosedProperty) == value)
return;
this.SetValue(IsClosedProperty, value);
OnIsClosedChanged();
}
}
private void OnIsClosedChanged() {
_rowDefContent.Height = new GridLength((IsClosed ? 0 : 1), GridUnitType.Star);
}
Obviously IsClosed
is not modified by the Designer and only IsClosedProperty
receives the xaml change.
My question is: How can I run IsClosed
after the value has been modified in the Designer. Or at least add some logic to the non-runtime changes.
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…