summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkihiko Odaki <akihiko.odaki.4i@stu.hosei.ac.jp>2016-08-16 18:05:42 (GMT)
committerJason Smith <jason.smith@xamarin.com>2016-08-16 18:05:42 (GMT)
commit966683a807f68f302e8f121279387109f2a4a73b (patch)
tree72ad57bdd02545d5c2741fc0a8e0bf606afb0368
parent414e5d1ec3712c526e8e527df948338d447f1ba1 (diff)
downloadxamarin-forms-966683a807f68f302e8f121279387109f2a4a73b.zip
xamarin-forms-966683a807f68f302e8f121279387109f2a4a73b.tar.gz
xamarin-forms-966683a807f68f302e8f121279387109f2a4a73b.tar.bz2
Invalidate measure of Label when FormattedText changes (#303)
-rw-r--r--Xamarin.Forms.Core.UnitTests/LabelTests.cs26
-rw-r--r--Xamarin.Forms.Core/Label.cs1
2 files changed, 27 insertions, 0 deletions
diff --git a/Xamarin.Forms.Core.UnitTests/LabelTests.cs b/Xamarin.Forms.Core.UnitTests/LabelTests.cs
index f56f792..5e2ffb5 100644
--- a/Xamarin.Forms.Core.UnitTests/LabelTests.cs
+++ b/Xamarin.Forms.Core.UnitTests/LabelTests.cs
@@ -46,6 +46,32 @@ namespace Xamarin.Forms.Core.UnitTests
}
[Test]
+ public void InvalidateMeasureWhenTextChanges ()
+ {
+ var label = new Label();
+
+ bool fired;
+ label.MeasureInvalidated += (sender, args) =>
+ {
+ fired = true;
+ };
+
+ fired = false;
+ label.Text = "Foo";
+ Assert.IsTrue (fired);
+
+ var fs = new FormattedString ();
+
+ fired = false;
+ label.FormattedText = fs;
+ Assert.IsTrue (fired);
+
+ fired = false;
+ fs.Spans.Add (new Span {Text = "bar"});
+ Assert.IsTrue (fired);
+ }
+
+ [Test]
public void AssignToFontStructUpdatesFontFamily (
[Values (NamedSize.Default, NamedSize.Large, NamedSize.Medium, NamedSize.Small, NamedSize.Micro)] NamedSize size,
[Values (FontAttributes.None, FontAttributes.Bold, FontAttributes.Italic, FontAttributes.Bold | FontAttributes.Italic)] FontAttributes attributes)
diff --git a/Xamarin.Forms.Core/Label.cs b/Xamarin.Forms.Core/Label.cs
index 1385b76..a6390b2 100644
--- a/Xamarin.Forms.Core/Label.cs
+++ b/Xamarin.Forms.Core/Label.cs
@@ -253,6 +253,7 @@ namespace Xamarin.Forms
void OnFormattedTextChanged(object sender, PropertyChangedEventArgs e)
{
+ InvalidateMeasureInternal(InvalidationTrigger.MeasureChanged);
OnPropertyChanged("FormattedText");
}