Browse Source

Fix Unit Tests & Value Restore on .NET Properties

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

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

@ -133,6 +133,11 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml
} }
} }
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.
@ -197,11 +202,6 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml
} }
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,11 +308,14 @@ 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