Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.

Commit

Permalink
[C] VisibilityConverter Trims input
Browse files Browse the repository at this point in the history
For CSS purposes, the VisibilityConverter was added, and actually
replaced the `Boolean.Parse(str)` call for parsing Visibility.
`Boolean.Parse()` trims input, and the converter was not, so this was a
regression.
This changes Trim() the input, to be fully backward compatible.

- fixes #3554
  • Loading branch information
StephaneDelcroix committed Aug 16, 2018
1 parent 03f8c9f commit b8c0024
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Xamarin.Forms.Core/VisualElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -920,13 +920,14 @@ public class VisibilityConverter : TypeConverter
{
public override object ConvertFromInvariantString(string value)
{
if (value != null)
value = value?.Trim();
if (!string.IsNullOrEmpty(value))
{
if (value.Equals("true", StringComparison.OrdinalIgnoreCase))
if (value.Equals(Boolean.TrueString, StringComparison.OrdinalIgnoreCase))
return true;
if (value.Equals("visible", StringComparison.OrdinalIgnoreCase))
return true;
if (value.Equals("false", StringComparison.OrdinalIgnoreCase))
if (value.Equals(Boolean.FalseString, StringComparison.OrdinalIgnoreCase))
return false;
if (value.Equals("hidden", StringComparison.OrdinalIgnoreCase))
return false;
Expand Down

0 comments on commit b8c0024

Please sign in to comment.