Skip to content

Commit 3878008

Browse files
authored
[Shell] Changed TitleProperty From TwoWay to OneWay (#29280)
* Make TitleProperty OneWay * Added a unit test
1 parent 970cb25 commit 3878008

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

src/Controls/src/Core/Shell/BaseShellItem.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public class BaseShellItem : NavigableElement, IPropertyPropagationController, I
5151

5252
/// <summary>Bindable property for <see cref="Title"/>.</summary>
5353
public static readonly BindableProperty TitleProperty =
54-
BindableProperty.Create(nameof(Title), typeof(string), typeof(BaseShellItem), null, BindingMode.TwoWay, propertyChanged: OnTitlePropertyChanged);
54+
BindableProperty.Create(nameof(Title), typeof(string), typeof(BaseShellItem), null, BindingMode.OneWay, propertyChanged: OnTitlePropertyChanged);
5555

5656
/// <summary>Bindable property for <see cref="IsVisible"/>.</summary>
5757
public static readonly BindableProperty IsVisibleProperty =

src/Controls/tests/Core.UnitTests/ShellTests.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1645,5 +1645,34 @@ public async Task ShellSectionChangedFires()
16451645
Assert.Equal(shell.CurrentPage, page2);
16461646
Assert.True(fired);
16471647
}
1648+
1649+
[Fact]
1650+
public void ShellContentTitleShouldNotBeAppliedMultipleTimesWithStringFormat()
1651+
{
1652+
var theLabel = new Label
1653+
{
1654+
Text = "Hello, World!",
1655+
AutomationId = "theLabel"
1656+
};
1657+
1658+
var contentPage = new ContentPage
1659+
{
1660+
Content = theLabel
1661+
};
1662+
1663+
ShellContent shellContent = new ShellContent
1664+
{
1665+
Content = contentPage,
1666+
};
1667+
1668+
shellContent.SetBinding(ShellContent.TitleProperty, new Binding
1669+
{
1670+
Source = theLabel,
1671+
Path = "Text",
1672+
StringFormat = "Title: {0}"
1673+
});
1674+
1675+
Assert.Equal("Title: Hello, World!", shellContent.Title);
1676+
}
16481677
}
16491678
}

0 commit comments

Comments
 (0)