Skip to content

Commit 20a70da

Browse files
StephaneDelcroixPureWeen
authored andcommitted
[C] Fix typo (#29379)
major facepalm - fixes #29336
1 parent e2fb92f commit 20a70da

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed

src/Controls/src/Core/BindableObject.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ public void SetValue(BindableProperty property, object value)
482482
if (property == null)
483483
throw new ArgumentNullException(nameof(property));
484484

485-
if (value is BindingBase binding && !property.ReturnType.IsAssignableFrom(typeof(BindableProperty)))
485+
if (value is BindingBase binding && !property.ReturnType.IsAssignableFrom(typeof(BindingBase)))
486486
{
487487
SetBinding(property, binding);
488488
return;
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
using Xunit;
2+
3+
namespace Microsoft.Maui.Controls.Core.UnitTests
4+
{
5+
public class ItemDisplayBindingTests
6+
{
7+
8+
class TestViewModel
9+
{
10+
public string Name { get; set; }
11+
public string Description { get; set; }
12+
}
13+
14+
class TestView : View
15+
{
16+
internal Picker picker = new Picker();
17+
public static readonly BindableProperty ItemDisplayBindingProperty = BindableProperty.Create(nameof(ItemDisplayBinding), typeof(BindingBase), typeof(TestView), propertyChanged: (bindable, _, newValue) =>
18+
{
19+
if (bindable is TestView view)
20+
{
21+
view.picker.ItemDisplayBinding = (BindingBase)newValue;
22+
}
23+
});
24+
25+
26+
public BindingBase ItemDisplayBinding
27+
{
28+
get => (BindingBase)GetValue(ItemDisplayBindingProperty);
29+
set => SetValue(ItemDisplayBindingProperty, value);
30+
}
31+
}
32+
33+
[Fact]
34+
public void TestItemDisplayBinding()
35+
{
36+
var testView = new TestView();
37+
38+
39+
var binding = new Binding("Name");
40+
testView.ItemDisplayBinding = binding;
41+
42+
Assert.Equal(binding, testView.ItemDisplayBinding);
43+
Assert.Equal(binding, testView.picker.ItemDisplayBinding);
44+
}
45+
46+
47+
}
48+
}

0 commit comments

Comments
 (0)