Skip to content

Commit

Permalink
feat: Implemented XamlReader support for ContentProperty syntax.
Browse files Browse the repository at this point in the history
  • Loading branch information
HavenDV committed Apr 11, 2022
1 parent 682456c commit 9f8d51d
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/Uno.UI/UI/Xaml/Markup/Reader/XamlObjectBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,23 @@ private void ProcessNamedMember(
{
ProcessSpan(control, span, member, rootInstance);
}
// WinUI assigned ContentProperty syntax
else if (
instance is ColumnDefinition columnDefinition &&
member.Member.Name == "_UnknownContent" &&
member.Value is string columnDefinitionContent &&
!string.IsNullOrWhiteSpace(columnDefinitionContent))
{
columnDefinition.Width = GridLength.ParseGridLength(columnDefinitionContent.Trim()).FirstOrDefault();
}
else if (
instance is RowDefinition rowDefinition &&
member.Member.Name == "_UnknownContent" &&
member.Value is string rowDefinitionContent &&
!string.IsNullOrWhiteSpace(rowDefinitionContent))
{
rowDefinition.Height = GridLength.ParseGridLength(rowDefinitionContent.Trim()).FirstOrDefault();
}
else if (member.Member.Name == "_UnknownContent"
&& TypeResolver.FindContentProperty(TypeResolver.FindType(control.Type)) == null
&& TypeResolver.IsCollectionOrListType(TypeResolver.FindType(control.Type)))
Expand Down Expand Up @@ -1008,7 +1025,6 @@ private void AddCollectionItems(object collectionInstance, IEnumerable<XamlObjec
if (member.Member.Name == "_UnknownContent")
{
var property = TypeResolver.FindContentProperty(TypeResolver.FindType(control.Type));

if (property == null)
{
throw new InvalidOperationException($"Implicit content is not supported on {control.Type}");
Expand Down

0 comments on commit 9f8d51d

Please sign in to comment.