Browse Source

Use string XamlBindingDefinition.SourcePropertyPath.

pull/237/head
Steven Kirk 11 years ago
parent
commit
3cb479769d
  1. 3
      src/Markup/Perspex.Markup.Xaml/DataBinding/PerspexPropertyBinder.cs
  2. 28
      src/Markup/Perspex.Markup.Xaml/DataBinding/XamlBindingDefinition.cs
  3. 8
      src/Markup/Perspex.Markup.Xaml/MarkupExtensions/BindingExtension.cs
  4. 6
      tests/Perspex.Markup.Xaml.UnitTests/BindingDefinitionBuilder.cs

3
src/Markup/Perspex.Markup.Xaml/DataBinding/PerspexPropertyBinder.cs

@ -5,6 +5,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using OmniXaml.TypeConversion;
using Perspex.Markup.Xaml.DataBinding.ChangeTracking;
namespace Perspex.Markup.Xaml.DataBinding
{
@ -47,7 +48,7 @@ namespace Perspex.Markup.Xaml.DataBinding
var binding = new XamlBinding(_typeConverterProvider)
{
BindingMode = xamlBinding.BindingMode,
SourcePropertyPath = xamlBinding.SourcePropertyPath,
SourcePropertyPath = new PropertyPath(xamlBinding.SourcePropertyPath),
Target = xamlBinding.Target,
TargetProperty = xamlBinding.TargetProperty
};

28
src/Markup/Perspex.Markup.Xaml/DataBinding/XamlBindingDefinition.cs

@ -2,31 +2,29 @@
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using Perspex.Controls;
using Perspex.Markup.Xaml.DataBinding.ChangeTracking;
namespace Perspex.Markup.Xaml.DataBinding
{
public class XamlBindingDefinition
{
private readonly PropertyPath _sourcePropertyPath;
private readonly BindingMode _bindingMode;
private readonly Control _target;
private readonly PerspexProperty _targetProperty;
public XamlBindingDefinition(Control target, PerspexProperty targetProperty, PropertyPath sourcePropertyPath, BindingMode bindingMode)
public XamlBindingDefinition(
Control target,
PerspexProperty targetProperty,
string sourcePropertyPath,
BindingMode bindingMode)
{
_target = target;
_targetProperty = targetProperty;
_sourcePropertyPath = sourcePropertyPath;
_bindingMode = bindingMode;
Target = target;
TargetProperty = targetProperty;
SourcePropertyPath = sourcePropertyPath;
BindingMode = bindingMode;
}
public Control Target => _target;
public Control Target { get; }
public PerspexProperty TargetProperty => _targetProperty;
public PerspexProperty TargetProperty { get; }
public PropertyPath SourcePropertyPath => _sourcePropertyPath;
public string SourcePropertyPath { get; }
public BindingMode BindingMode => _bindingMode;
public BindingMode BindingMode { get; }
}
}

8
src/Markup/Perspex.Markup.Xaml/MarkupExtensions/BindingExtension.cs

@ -27,13 +27,7 @@ namespace Perspex.Markup.Xaml.MarkupExtensions
var targetPropertyName = targetProperty.Name;
var perspexProperty = target.GetRegisteredProperties().First(property => property.Name == targetPropertyName);
return new XamlBindingDefinition
(
target,
perspexProperty,
new PropertyPath(Path),
Mode == BindingMode.Default ? BindingMode.OneWay : Mode
);
return new XamlBindingDefinition(target, perspexProperty, Path, Mode);
}
/// <summary> The source path (for CLR bindings).</summary>

6
tests/Perspex.Markup.Xaml.UnitTests/BindingDefinitionBuilder.cs

@ -1,24 +1,22 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using Perspex.Controls;
using Perspex.Markup.Xaml.DataBinding;
using Perspex.Markup.Xaml.DataBinding.ChangeTracking;
namespace Perspex.Xaml.Base.UnitTest
{
public class BindingDefinitionBuilder
{
private readonly BindingMode _bindingMode;
private readonly PropertyPath _sourcePropertyPath;
private readonly string _sourcePropertyPath;
private Control _target;
private PerspexProperty _targetProperty;
public BindingDefinitionBuilder()
{
_bindingMode = BindingMode.Default;
_sourcePropertyPath = new PropertyPath(string.Empty);
_sourcePropertyPath = string.Empty;
}
public BindingDefinitionBuilder WithNullTarget()

Loading…
Cancel
Save