diff options
Diffstat (limited to 'Xamarin.Forms.Core/Cells/ViewCell.cs')
-rw-r--r-- | Xamarin.Forms.Core/Cells/ViewCell.cs | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/Xamarin.Forms.Core/Cells/ViewCell.cs b/Xamarin.Forms.Core/Cells/ViewCell.cs new file mode 100644 index 00000000..334822f6 --- /dev/null +++ b/Xamarin.Forms.Core/Cells/ViewCell.cs @@ -0,0 +1,48 @@ +using System.Collections.Generic; +using System.Collections.ObjectModel; + +namespace Xamarin.Forms +{ + [ContentProperty("View")] + public class ViewCell : Cell + { + ReadOnlyCollection<Element> _logicalChildren; + + View _view; + + public View View + { + get { return _view; } + set + { + if (_view == value) + return; + + OnPropertyChanging(); + + if (_view != null) + { + OnChildRemoved(_view); + _view.ComputedConstraint = LayoutConstraint.None; + } + + _view = value; + + if (_view != null) + { + _view.ComputedConstraint = LayoutConstraint.Fixed; + OnChildAdded(_view); + _logicalChildren = new ReadOnlyCollection<Element>(new List<Element>(new[] { View })); + } + else + { + _logicalChildren = null; + } + + OnPropertyChanged(); + } + } + + internal override ReadOnlyCollection<Element> LogicalChildren => _logicalChildren ?? base.LogicalChildren; + } +}
\ No newline at end of file |