Skip to content

Commit

Permalink
Merge pull request #17674 from Youssef1313/fix-binding
Browse files Browse the repository at this point in the history
fix: Fix parameterless Binding constructor not having correct defaults
  • Loading branch information
jeromelaban authored Jul 25, 2024
2 parents 4ee4642 + 88da65d commit 161c3c1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Threading.Tasks;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Media;
using Private.Infrastructure;
using Uno.Disposables;
Expand All @@ -8,6 +9,15 @@ namespace Uno.UI.RuntimeTests.Tests.Windows_UI_Xaml_Data;
[TestClass]
public class Given_BindingExpression
{
[TestMethod]
[RunsOnUIThread]
public async Task When_Binding_Should_Have_Correct_Default()
{
var binding = new Binding();
Assert.AreEqual(BindingMode.OneWay, binding.Mode);
Assert.AreEqual("", binding.ConverterLanguage);
}

[TestMethod]
[RunsOnUIThread]
public async Task When_Binding_Outer_Inner_DC_Null()
Expand Down
6 changes: 2 additions & 4 deletions src/Uno.UI/UI/Xaml/Data/Binding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ public partial class Binding : BindingBase

public Binding()
{

}

/// <summary>
Expand All @@ -68,7 +67,6 @@ public Binding()
Path = path ?? new PropertyPath(String.Empty);
Converter = converter;
ConverterParameter = converterParameter;
Mode = BindingMode.OneWay;
}

public static implicit operator Binding(string path)
Expand Down Expand Up @@ -98,7 +96,7 @@ public static implicit operator Binding(string path)
/// Gets or sets a value that names the language to pass to any converter specified by the Converter property.
/// </summary>
/// <value>The converter language.</value>
public string ConverterLanguage { get; set; }
public string ConverterLanguage { get; set; } = "";

/// <summary>
/// Gets or sets the name of the element to use as the binding source for the Binding.
Expand Down Expand Up @@ -129,7 +127,7 @@ public object FallbackValue
/// Gets or sets a value that indicates the direction of the data flow in the binding.
/// </summary>
/// <value>The mode.</value>
public BindingMode Mode { get; set; }
public BindingMode Mode { get; set; } = BindingMode.OneWay;

/// <summary>
/// Gets or sets the binding source by specifying its location relative to the position of the binding target. This is most often used in bindings within XAML control templates.
Expand Down

0 comments on commit 161c3c1

Please sign in to comment.