Browse Source

Fix Unit Tests & Value Restore on .NET Properties

pull/690/head
jkuehner 10 years ago
parent
commit
1d9266c15d
  1. 29
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlModelProperty.cs

29
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlModelProperty.cs

@ -132,7 +132,12 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml
return null; return null;
} }
} }
internal void SetValueOnInstance(object value)
{
_property.ValueOnInstance = value;
}
// There may be multiple XamlModelProperty instances for the same property, // There may be multiple XamlModelProperty instances for the same property,
// so this class may not have any mutable fields / events - instead, // so this class may not have any mutable fields / events - instead,
// we forward all event handlers to the XamlProperty. // we forward all event handlers to the XamlProperty.
@ -195,13 +200,8 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml
_property.IsSetChanged -= value; _property.IsSetChanged -= value;
} }
} }
public override void SetValue(object value) public override void SetValue(object value)
{
SetValue(value, false);
}
private void SetValue(object value, bool withoutUndo)
{ {
XamlPropertyValue newValue; XamlPropertyValue newValue;
if (value == null) { if (value == null) {
@ -223,7 +223,7 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml
} }
UndoService undoService = _designItem.Services.GetService<UndoService>(); UndoService undoService = _designItem.Services.GetService<UndoService>();
if (undoService != null && !withoutUndo) if (undoService != null)
undoService.Execute(new PropertyChangeAction(this, newValue, true)); undoService.Execute(new PropertyChangeAction(this, newValue, true));
else else
SetValueInternal(newValue); SetValueInternal(newValue);
@ -308,12 +308,15 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml
} }
} }
else { else {
try { if (property.DependencyProperty == null) {
property.SetValue(oldValueOnInstance, true); try
{
property.SetValueOnInstance(oldValueOnInstance);
}
catch(Exception)
{ }
} }
catch(Exception)
{ }
property.ResetInternal(); property.ResetInternal();
} }
} }

Loading…
Cancel
Save