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 b748895 commit ab87f00
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/Uno.UI/UI/Xaml/Controls/Grid/ColumnDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
using System.Text;
using Uno.UI.DataBinding;
using Uno.UI.Xaml;
using Windows.UI.Xaml.Markup;

namespace Windows.UI.Xaml.Controls
{
[DebuggerDisplay("{DebugDisplay,nq}")]
[ContentProperty(Name = "Content")]
public partial class ColumnDefinition : DefinitionBase, DependencyObject
{
public ColumnDefinition()
Expand All @@ -23,6 +25,21 @@ internal void OnPropertyChanged2(DependencyPropertyChangedEventArgs args)
InvalidateDefinition();
}

// New WinUI assigned ContentProperty syntax
public virtual object Content
{
set
{
if (value is not string stringValue ||
string.IsNullOrWhiteSpace(stringValue))
{
return;
}

Width = GridLength.ParseGridLength(stringValue.Trim()).FirstOrDefault();
}
}

#region Width DependencyProperty

private static GridLength GetWidthDefaultValue() => GridLengthHelper.OneStar;
Expand Down
17 changes: 17 additions & 0 deletions src/Uno.UI/UI/Xaml/Controls/Grid/RowDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
using System.Linq;
using System.Text;
using Uno.UI.Xaml;
using Windows.UI.Xaml.Markup;

namespace Windows.UI.Xaml.Controls
{
[DebuggerDisplay("{DebugDisplay,nq}")]
[ContentProperty(Name = "Content")]
public partial class RowDefinition : DefinitionBase, DependencyObject
{
public RowDefinition()
Expand All @@ -22,6 +24,21 @@ internal void OnPropertyChanged2(DependencyPropertyChangedEventArgs args)
InvalidateDefinition();
}

// New WinUI assigned ContentProperty syntax
public virtual object Content
{
set
{
if (value is not string stringValue ||
string.IsNullOrWhiteSpace(stringValue))
{
return;
}

Height = GridLength.ParseGridLength(stringValue.Trim()).FirstOrDefault();
}
}

#region Height DependencyProperty

private static GridLength GetHeightDefaultValue() => GridLengthHelper.OneStar;
Expand Down

0 comments on commit ab87f00

Please sign in to comment.