Browse Source

Correctly set binding priority from Setter.

pull/464/head
Steven Kirk 11 years ago
parent
commit
cffc67e117
  1. 69
      src/Perspex.Styling/Styling/Setter.cs

69
src/Perspex.Styling/Styling/Setter.cs

@ -94,38 +94,57 @@ namespace Perspex.Styling
} }
else else
{ {
if (activator == null) var source = binding.Initiate(control, Property);
if (source != null)
{ {
control.Bind(Property, binding); var cloned = Clone(source, style, activator);
BindingOperations.Apply(control, Property, cloned, null);
} }
else }
{ }
var sourceInstance = binding.Initiate(control, Property);
if (sourceInstance != null) private InstancedBinding Clone(InstancedBinding sourceInstance, IStyle style, IObservable<bool> activator)
{ {
InstancedBinding activatedInstance; InstancedBinding cloned;
if (sourceInstance.Subject != null) if (activator != null)
{ {
var activated = new ActivatedSubject(activator, sourceInstance.Subject, description); var description = style?.ToString();
activatedInstance = new InstancedBinding(activated, sourceInstance.Mode, sourceInstance.Priority);
}
else if (sourceInstance.Observable != null)
{
var activated = new ActivatedObservable(activator, sourceInstance.Observable, description);
activatedInstance = new InstancedBinding(activated, sourceInstance.Mode, sourceInstance.Priority);
}
else
{
var activated = new ActivatedValue(activator, sourceInstance.Value, description);
activatedInstance = new InstancedBinding(activated, BindingMode.OneWay, sourceInstance.Priority);
}
BindingOperations.Apply(control, Property, activatedInstance, null); if (sourceInstance.Subject != null)
} {
var activated = new ActivatedSubject(activator, sourceInstance.Subject, description);
cloned = new InstancedBinding(activated, sourceInstance.Mode, BindingPriority.StyleTrigger);
}
else if (sourceInstance.Observable != null)
{
var activated = new ActivatedObservable(activator, sourceInstance.Observable, description);
cloned = new InstancedBinding(activated, sourceInstance.Mode, BindingPriority.StyleTrigger);
}
else
{
var activated = new ActivatedValue(activator, sourceInstance.Value, description);
cloned = new InstancedBinding(activated, BindingMode.OneWay, BindingPriority.StyleTrigger);
}
}
else
{
if (sourceInstance.Subject != null)
{
cloned = new InstancedBinding(sourceInstance.Subject, sourceInstance.Mode, BindingPriority.Style);
}
else if (sourceInstance.Observable != null)
{
cloned = new InstancedBinding(sourceInstance.Observable, sourceInstance.Mode, BindingPriority.Style);
}
else
{
cloned = new InstancedBinding(sourceInstance.Value, BindingPriority.Style);
} }
} }
return cloned;
} }
} }
} }

Loading…
Cancel
Save