Skip to content

Commit

Permalink
fix: BindingExpression failed to apply string explicit source.
Browse files Browse the repository at this point in the history
  • Loading branch information
alove-kahua committed Nov 6, 2020
1 parent d57b9ad commit 94b6bc9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
17 changes: 17 additions & 0 deletions src/Uno.UI.Tests/BinderTests/Given_Binder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,23 @@ public void When_Source_Complex()
Assert.AreEqual(42, SUT.Tag);
}

[TestMethod]
public void When_Source_String()
{
var source = "Test";
var SUT = new Windows.UI.Xaml.Controls.Grid();

SUT.SetBinding(
Windows.UI.Xaml.Controls.Grid.TagProperty,
new Binding()
{
Source = source
}
);

Assert.AreEqual(source, SUT.Tag);
}

[TestMethod]
public void When_Subject_Source_Complex()
{
Expand Down
7 changes: 0 additions & 7 deletions src/Uno.UI/DataBinding/BindingExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -347,13 +347,6 @@ private void ApplyExplicitSource()
this.Log().DebugFormat("Applying explicit source {0} on {1}", ExplicitSource?.GetType(), _view.Target?.GetType());
}

var resourceName = ExplicitSource as string;

if (resourceName.HasValue())
{
_dataContext = Uno.UI.DataBinding.WeakReferencePool.RentWeakReference(this, ResourceHelper.FindResource(resourceName));
}

ApplyBinding();
}
}
Expand Down

0 comments on commit 94b6bc9

Please sign in to comment.