Skip to content

Commit

Permalink
feat: Implemented XamlReader support for succinct syntax.
Browse files Browse the repository at this point in the history
  • Loading branch information
HavenDV committed Apr 11, 2022
1 parent ab87f00 commit 8057b0c
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion src/Uno.UI/UI/Xaml/Markup/Reader/XamlObjectBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,40 @@ private void ProcessNamedMember(
|| IsResourcesProperty(propertyInfo)
)
{
// Empty collection
// New grid succinct syntax.
if (instance is Grid grid &&
(member.Member.Name == "ColumnDefinitions" || member.Member.Name == "RowDefinitions") &&
member.Member.PreferredXamlNamespace == XamlConstants.PresentationXamlXmlNamespace &&
member.Value is string definitions)
{
var values = definitions
.Split(',')
.Select(static definition => definition.Trim())
.ToArray();

foreach (var value in values)
{
var gridLength = GridLength.ParseGridLength(value).FirstOrDefault();
if (member.Member.Name == "ColumnDefinitions")
{
grid.ColumnDefinitions.Add(new ColumnDefinition
{
Width = gridLength,
});
}
else
{
grid.RowDefinitions.Add(new RowDefinition
{
Height = gridLength,
});
}
}
}
else
{
// Empty collection
}
}
else
{
Expand Down

0 comments on commit 8057b0c

Please sign in to comment.