BindingDefinitionBuilder.cs 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. // Copyright (c) The Perspex Project. All rights reserved.
  2. // Licensed under the MIT license. See licence.md file in the project root for full license information.
  3. using Perspex.Controls;
  4. using Perspex.Markup.Xaml.DataBinding;
  5. namespace Perspex.Xaml.Base.UnitTest
  6. {
  7. public class BindingDefinitionBuilder
  8. {
  9. private readonly BindingMode _bindingMode;
  10. private readonly string _sourcePropertyPath;
  11. private Control _target;
  12. public BindingDefinitionBuilder()
  13. {
  14. _bindingMode = BindingMode.Default;
  15. _sourcePropertyPath = string.Empty;
  16. }
  17. public BindingDefinitionBuilder WithNullTarget()
  18. {
  19. _target = null;
  20. return this;
  21. }
  22. public XamlBindingDefinition Build()
  23. {
  24. return new XamlBindingDefinition(
  25. bindingMode: _bindingMode,
  26. sourcePropertyPath: _sourcePropertyPath,
  27. target: _target,
  28. targetProperty: null);
  29. }
  30. }
  31. }