diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla37462.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla37462.cs index 6e3c3aab792..89c3b03223a 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla37462.cs +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla37462.cs @@ -22,7 +22,7 @@ protected override void Init () var label1 = new Label { Text = "This is a label on page 1" }; page1.Content = new StackLayout { Children = { button1, label1 } }; page1.Appearing += (sender, args) => { - page1.InvalidateMeasure (InvalidationTrigger.MeasureChanged); + ((IVisualElementController)page1).InvalidateMeasure(InvalidationTrigger.MeasureChanged); }; var page2 = new ContentPage { Title = "Page 2" }; diff --git a/Xamarin.Forms.Core.UnitTests/GridTests.cs b/Xamarin.Forms.Core.UnitTests/GridTests.cs index 203d3b6416b..359d2b5bb5b 100644 --- a/Xamarin.Forms.Core.UnitTests/GridTests.cs +++ b/Xamarin.Forms.Core.UnitTests/GridTests.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Linq; +using Xamarin.Forms.Internals; namespace Xamarin.Forms.Core.UnitTests { @@ -1555,7 +1556,7 @@ public void NestedInvalidateMeasureDoesNotCrash () bool fire = true; child.SizeChanged += (sender, args) => { if (fire) - child.InvalidateMeasure (InvalidationTrigger.Undefined); + ((IVisualElementController)child).InvalidateMeasure(InvalidationTrigger.Undefined); fire = false; }; diff --git a/Xamarin.Forms.Core/AbsoluteLayout.cs b/Xamarin.Forms.Core/AbsoluteLayout.cs index 51b5ca124eb..aceec2b3f8f 100644 --- a/Xamarin.Forms.Core/AbsoluteLayout.cs +++ b/Xamarin.Forms.Core/AbsoluteLayout.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; +using Xamarin.Forms.Internals; namespace Xamarin.Forms { @@ -132,7 +133,7 @@ void ChildOnPropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == LayoutFlagsProperty.PropertyName || e.PropertyName == LayoutBoundsProperty.PropertyName) { - InvalidateMeasure(InvalidationTrigger.MeasureChanged); + InvalidateMeasureInternal(InvalidationTrigger.MeasureChanged); UpdateChildrenLayout(); } } diff --git a/Xamarin.Forms.Core/Button.cs b/Xamarin.Forms.Core/Button.cs index 9c746c9e958..72f98814aab 100644 --- a/Xamarin.Forms.Core/Button.cs +++ b/Xamarin.Forms.Core/Button.cs @@ -2,6 +2,7 @@ using System.Diagnostics; using System.Globalization; using System.Windows.Input; +using Xamarin.Forms.Internals; using Xamarin.Forms.Platform; namespace Xamarin.Forms @@ -18,7 +19,7 @@ public class Button : View, IFontElement, IButtonController BindableProperty.Create("ContentLayout", typeof(ButtonContentLayout), typeof(Button), new ButtonContentLayout(ButtonContentLayout.ImagePosition.Left, DefaultSpacing)); public static readonly BindableProperty TextProperty = BindableProperty.Create("Text", typeof(string), typeof(Button), null, - propertyChanged: (bindable, oldVal, newVal) => ((Button)bindable).InvalidateMeasure(InvalidationTrigger.MeasureChanged)); + propertyChanged: (bindable, oldVal, newVal) => ((Button)bindable).InvalidateMeasureInternal(InvalidationTrigger.MeasureChanged)); public static readonly BindableProperty TextColorProperty = BindableProperty.Create("TextColor", typeof(Color), typeof(Button), Color.Default); @@ -178,7 +179,7 @@ static void FontStructPropertyChanged(BindableObject bindable, object oldValue, if (button._cancelEvents) return; - button.InvalidateMeasure(InvalidationTrigger.MeasureChanged); + button.InvalidateMeasureInternal(InvalidationTrigger.MeasureChanged); button._cancelEvents = true; @@ -219,7 +220,7 @@ void OnCommandChanged() void OnSourceChanged(object sender, EventArgs eventArgs) { OnPropertyChanged(ImageProperty.PropertyName); - InvalidateMeasure(InvalidationTrigger.MeasureChanged); + InvalidateMeasureInternal(InvalidationTrigger.MeasureChanged); } void OnSourcePropertyChanged(ImageSource oldvalue, ImageSource newvalue) @@ -229,7 +230,7 @@ void OnSourcePropertyChanged(ImageSource oldvalue, ImageSource newvalue) newvalue.SourceChanged += OnSourceChanged; SetInheritedBindingContext(newvalue, BindingContext); } - InvalidateMeasure(InvalidationTrigger.MeasureChanged); + InvalidateMeasureInternal(InvalidationTrigger.MeasureChanged); } void OnSourcePropertyChanging(ImageSource oldvalue, ImageSource newvalue) @@ -245,7 +246,7 @@ static void SpecificFontPropertyChanged(BindableObject bindable, object oldValue if (button._cancelEvents) return; - button.InvalidateMeasure(InvalidationTrigger.MeasureChanged); + button.InvalidateMeasureInternal(InvalidationTrigger.MeasureChanged); button._cancelEvents = true; diff --git a/Xamarin.Forms.Core/Grid.cs b/Xamarin.Forms.Core/Grid.cs index 442146c2e8d..a0460af5552 100644 --- a/Xamarin.Forms.Core/Grid.cs +++ b/Xamarin.Forms.Core/Grid.cs @@ -3,6 +3,7 @@ using System.Collections.ObjectModel; using System.ComponentModel; using System.Linq; +using Xamarin.Forms.Internals; namespace Xamarin.Forms { @@ -17,10 +18,10 @@ public partial class Grid : Layout public static readonly BindableProperty ColumnSpanProperty = BindableProperty.CreateAttached("ColumnSpan", typeof(int), typeof(Grid), 1, validateValue: (bindable, value) => (int)value >= 1); public static readonly BindableProperty RowSpacingProperty = BindableProperty.Create("RowSpacing", typeof(double), typeof(Grid), 6d, - propertyChanged: (bindable, oldValue, newValue) => ((Grid)bindable).InvalidateMeasure(InvalidationTrigger.MeasureChanged)); + propertyChanged: (bindable, oldValue, newValue) => ((Grid)bindable).InvalidateMeasureInternal(InvalidationTrigger.MeasureChanged)); public static readonly BindableProperty ColumnSpacingProperty = BindableProperty.Create("ColumnSpacing", typeof(double), typeof(Grid), 6d, - propertyChanged: (bindable, oldValue, newValue) => ((Grid)bindable).InvalidateMeasure(InvalidationTrigger.MeasureChanged)); + propertyChanged: (bindable, oldValue, newValue) => ((Grid)bindable).InvalidateMeasureInternal(InvalidationTrigger.MeasureChanged)); public static readonly BindableProperty ColumnDefinitionsProperty = BindableProperty.Create("ColumnDefinitions", typeof(ColumnDefinitionCollection), typeof(Grid), null, validateValue: (bindable, value) => value != null, propertyChanged: (bindable, oldvalue, newvalue) => @@ -211,9 +212,9 @@ internal override void ComputeConstraintForView(View view) view.ComputedConstraint = result; } - internal override void InvalidateMeasure(InvalidationTrigger trigger) + internal override void InvalidateMeasureInternal(InvalidationTrigger trigger) { - base.InvalidateMeasure(trigger); + base.InvalidateMeasureInternal(trigger); _columns = null; _rows = null; } diff --git a/Xamarin.Forms.Core/IVisualElementController.cs b/Xamarin.Forms.Core/IVisualElementController.cs index 03be293a536..672f47dedb2 100644 --- a/Xamarin.Forms.Core/IVisualElementController.cs +++ b/Xamarin.Forms.Core/IVisualElementController.cs @@ -1,7 +1,10 @@ +using Xamarin.Forms.Internals; + namespace Xamarin.Forms { public interface IVisualElementController : IElementController { void NativeSizeChanged(); + void InvalidateMeasure(InvalidationTrigger trigger); } } \ No newline at end of file diff --git a/Xamarin.Forms.Core/Image.cs b/Xamarin.Forms.Core/Image.cs index 4528f3b95d2..7d6299ac298 100644 --- a/Xamarin.Forms.Core/Image.cs +++ b/Xamarin.Forms.Core/Image.cs @@ -1,4 +1,5 @@ using System; +using Xamarin.Forms.Internals; using Xamarin.Forms.Platform; namespace Xamarin.Forms @@ -110,7 +111,7 @@ protected override SizeRequest OnSizeRequest(double widthConstraint, double heig void OnSourceChanged(object sender, EventArgs eventArgs) { OnPropertyChanged(SourceProperty.PropertyName); - InvalidateMeasure(InvalidationTrigger.MeasureChanged); + InvalidateMeasureInternal(InvalidationTrigger.MeasureChanged); } static void OnSourcePropertyChanged(BindableObject bindable, object oldvalue, object newvalue) @@ -125,7 +126,7 @@ void OnSourcePropertyChanged(ImageSource oldvalue, ImageSource newvalue) newvalue.SourceChanged += OnSourceChanged; SetInheritedBindingContext(newvalue, BindingContext); } - InvalidateMeasure(InvalidationTrigger.MeasureChanged); + InvalidateMeasureInternal(InvalidationTrigger.MeasureChanged); } static void OnSourcePropertyChanging(BindableObject bindable, object oldvalue, object newvalue) diff --git a/Xamarin.Forms.Core/InvalidationTrigger.cs b/Xamarin.Forms.Core/Internals/InvalidationTrigger.cs similarity index 77% rename from Xamarin.Forms.Core/InvalidationTrigger.cs rename to Xamarin.Forms.Core/Internals/InvalidationTrigger.cs index e7db534e81f..9a4180e46c1 100644 --- a/Xamarin.Forms.Core/InvalidationTrigger.cs +++ b/Xamarin.Forms.Core/Internals/InvalidationTrigger.cs @@ -1,9 +1,9 @@ using System; -namespace Xamarin.Forms +namespace Xamarin.Forms.Internals { [Flags] - internal enum InvalidationTrigger + public enum InvalidationTrigger { Undefined = 0, MeasureChanged = 1 << 0, diff --git a/Xamarin.Forms.Core/InvalidationEventArgs.cs b/Xamarin.Forms.Core/InvalidationEventArgs.cs index d88e251922c..1dd5c098c76 100644 --- a/Xamarin.Forms.Core/InvalidationEventArgs.cs +++ b/Xamarin.Forms.Core/InvalidationEventArgs.cs @@ -1,4 +1,5 @@ using System; +using Xamarin.Forms.Internals; namespace Xamarin.Forms { diff --git a/Xamarin.Forms.Core/Label.cs b/Xamarin.Forms.Core/Label.cs index 1efbd668d0a..1385b7639bd 100644 --- a/Xamarin.Forms.Core/Label.cs +++ b/Xamarin.Forms.Core/Label.cs @@ -1,5 +1,6 @@ using System; using System.ComponentModel; +using Xamarin.Forms.Internals; using Xamarin.Forms.Platform; namespace Xamarin.Forms @@ -41,13 +42,13 @@ public class Label : View, IFontElement { if (newvalue != null) ((FormattedString)newvalue).PropertyChanged += ((Label)bindable).OnFormattedTextChanged; - ((Label)bindable).InvalidateMeasure(InvalidationTrigger.MeasureChanged); + ((Label)bindable).InvalidateMeasureInternal(InvalidationTrigger.MeasureChanged); if (newvalue != null) ((Label)bindable).Text = null; }); public static readonly BindableProperty LineBreakModeProperty = BindableProperty.Create("LineBreakMode", typeof(LineBreakMode), typeof(Label), LineBreakMode.WordWrap, - propertyChanged: (bindable, oldvalue, newvalue) => ((Label)bindable).InvalidateMeasure(InvalidationTrigger.MeasureChanged)); + propertyChanged: (bindable, oldvalue, newvalue) => ((Label)bindable).InvalidateMeasureInternal(InvalidationTrigger.MeasureChanged)); bool _cancelEvents; @@ -158,7 +159,7 @@ static void FontStructPropertyChanged(BindableObject bindable, object oldValue, label._cancelEvents = false; - label.InvalidateMeasure(InvalidationTrigger.MeasureChanged); + label.InvalidateMeasureInternal(InvalidationTrigger.MeasureChanged); } static void OnFontAttributesChanged(BindableObject bindable, object oldValue, object newValue) @@ -189,7 +190,7 @@ static void OnFontAttributesChanged(BindableObject bindable, object oldValue, ob label._cancelEvents = false; - label.InvalidateMeasure(InvalidationTrigger.MeasureChanged); + label.InvalidateMeasureInternal(InvalidationTrigger.MeasureChanged); } static void OnFontFamilyChanged(BindableObject bindable, object oldValue, object newValue) @@ -217,7 +218,7 @@ static void OnFontFamilyChanged(BindableObject bindable, object oldValue, object } label._cancelEvents = false; - label.InvalidateMeasure(InvalidationTrigger.MeasureChanged); + label.InvalidateMeasureInternal(InvalidationTrigger.MeasureChanged); } static void OnFontSizeChanged(BindableObject bindable, object oldValue, object newValue) @@ -247,7 +248,7 @@ static void OnFontSizeChanged(BindableObject bindable, object oldValue, object n label._cancelEvents = false; - label.InvalidateMeasure(InvalidationTrigger.MeasureChanged); + label.InvalidateMeasureInternal(InvalidationTrigger.MeasureChanged); } void OnFormattedTextChanged(object sender, PropertyChangedEventArgs e) @@ -270,7 +271,7 @@ static void OnTextPropertyChanged(BindableObject bindable, object oldvalue, obje bool isVerticallyFixed = (label.Constraint & LayoutConstraint.VerticallyFixed) != 0; bool isSingleLine = !(breakMode == LineBreakMode.CharacterWrap || breakMode == LineBreakMode.WordWrap); if (!isVerticallyFixed || !isSingleLine) - ((Label)bindable).InvalidateMeasure(InvalidationTrigger.MeasureChanged); + ((Label)bindable).InvalidateMeasureInternal(InvalidationTrigger.MeasureChanged); if (newvalue != null) ((Label)bindable).FormattedText = null; } diff --git a/Xamarin.Forms.Core/Layout.cs b/Xamarin.Forms.Core/Layout.cs index a7864070a91..a98e46a121c 100644 --- a/Xamarin.Forms.Core/Layout.cs +++ b/Xamarin.Forms.Core/Layout.cs @@ -3,6 +3,7 @@ using System.Collections.ObjectModel; using System.Collections.Specialized; using System.Linq; +using Xamarin.Forms.Internals; namespace Xamarin.Forms { @@ -168,7 +169,7 @@ public void RaiseChild(View view) protected virtual void InvalidateLayout() { _hasDoneLayout = false; - InvalidateMeasure(InvalidationTrigger.MeasureChanged); + InvalidateMeasureInternal(InvalidationTrigger.MeasureChanged); if (!_hasDoneLayout) ForceLayout(); } @@ -304,11 +305,11 @@ internal virtual void OnChildMeasureInvalidated(VisualElement child, Invalidatio _allocatedFlag = false; if (trigger == InvalidationTrigger.RendererReady) { - InvalidateMeasure(InvalidationTrigger.RendererReady); + InvalidateMeasureInternal(InvalidationTrigger.RendererReady); } else { - InvalidateMeasure(InvalidationTrigger.MeasureChanged); + InvalidateMeasureInternal(InvalidationTrigger.MeasureChanged); } s_resolutionList.Add(new KeyValuePair(this, GetElementDepth(this))); diff --git a/Xamarin.Forms.Core/Page.cs b/Xamarin.Forms.Core/Page.cs index 903f4b536c6..2e1caf0f57c 100644 --- a/Xamarin.Forms.Core/Page.cs +++ b/Xamarin.Forms.Core/Page.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; +using Xamarin.Forms.Internals; using Xamarin.Forms.Platform; namespace Xamarin.Forms @@ -283,7 +284,7 @@ internal virtual void OnChildMeasureInvalidated(VisualElement child, Invalidatio } _allocatedFlag = false; - InvalidateMeasure(InvalidationTrigger.MeasureChanged); + InvalidateMeasureInternal(InvalidationTrigger.MeasureChanged); if (!_allocatedFlag && Width >= 0 && Height >= 0) { SizeAllocated(Width, Height); @@ -348,7 +349,7 @@ void OnInternalAdded(VisualElement view) view.MeasureInvalidated += OnChildMeasureInvalidated; OnChildAdded(view); - InvalidateMeasure(InvalidationTrigger.MeasureChanged); + InvalidateMeasureInternal(InvalidationTrigger.MeasureChanged); } void OnInternalRemoved(VisualElement view) diff --git a/Xamarin.Forms.Core/StackLayout.cs b/Xamarin.Forms.Core/StackLayout.cs index 4dc7bfa379b..e115a23d48c 100644 --- a/Xamarin.Forms.Core/StackLayout.cs +++ b/Xamarin.Forms.Core/StackLayout.cs @@ -1,4 +1,5 @@ using System; +using Xamarin.Forms.Internals; namespace Xamarin.Forms { @@ -73,10 +74,10 @@ internal override void ComputeConstraintForView(View view) ComputeConstraintForView(view, false); } - internal override void InvalidateMeasure(InvalidationTrigger trigger) + internal override void InvalidateMeasureInternal(InvalidationTrigger trigger) { _layoutInformation = new LayoutInformation(); - base.InvalidateMeasure(trigger); + base.InvalidateMeasureInternal(trigger); } void AlignOffAxis(LayoutInformation layout, StackOrientation orientation, double widthConstraint, double heightConstraint) diff --git a/Xamarin.Forms.Core/View.cs b/Xamarin.Forms.Core/View.cs index d03c74bb5a3..1ff51d9c9d3 100644 --- a/Xamarin.Forms.Core/View.cs +++ b/Xamarin.Forms.Core/View.cs @@ -3,16 +3,17 @@ using System.Collections.ObjectModel; using System.Collections.Specialized; using System.Linq; +using Xamarin.Forms.Internals; namespace Xamarin.Forms { public class View : VisualElement, IViewController { public static readonly BindableProperty VerticalOptionsProperty = BindableProperty.Create("VerticalOptions", typeof(LayoutOptions), typeof(View), LayoutOptions.Fill, - propertyChanged: (bindable, oldvalue, newvalue) => ((View)bindable).InvalidateMeasure(InvalidationTrigger.VerticalOptionsChanged)); + propertyChanged: (bindable, oldvalue, newvalue) => ((View)bindable).InvalidateMeasureInternal(InvalidationTrigger.VerticalOptionsChanged)); public static readonly BindableProperty HorizontalOptionsProperty = BindableProperty.Create("HorizontalOptions", typeof(LayoutOptions), typeof(View), LayoutOptions.Fill, - propertyChanged: (bindable, oldvalue, newvalue) => ((View)bindable).InvalidateMeasure(InvalidationTrigger.HorizontalOptionsChanged)); + propertyChanged: (bindable, oldvalue, newvalue) => ((View)bindable).InvalidateMeasureInternal(InvalidationTrigger.HorizontalOptionsChanged)); public static readonly BindableProperty MarginProperty = BindableProperty.Create("Margin", typeof(Thickness), typeof(View), default(Thickness), propertyChanged: MarginPropertyChanged); @@ -100,7 +101,7 @@ protected override void OnBindingContextChanged() static void MarginPropertyChanged(BindableObject bindable, object oldValue, object newValue) { - ((View)bindable).InvalidateMeasure(InvalidationTrigger.MarginChanged); + ((View)bindable).InvalidateMeasureInternal(InvalidationTrigger.MarginChanged); } void ValidateGesture(IGestureRecognizer gesture) diff --git a/Xamarin.Forms.Core/VisualElement.cs b/Xamarin.Forms.Core/VisualElement.cs index e93dea6c609..da8b8292e5b 100644 --- a/Xamarin.Forms.Core/VisualElement.cs +++ b/Xamarin.Forms.Core/VisualElement.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using Xamarin.Forms.Internals; namespace Xamarin.Forms { @@ -353,7 +354,7 @@ internal bool IsNativeStateConsistent return; _isNativeStateConsistent = value; if (value && IsPlatformEnabled) - InvalidateMeasure(InvalidationTrigger.RendererReady); + InvalidateMeasureInternal(InvalidationTrigger.RendererReady); } } @@ -367,7 +368,7 @@ internal bool IsPlatformEnabled _isPlatformEnabled = value; if (value && IsNativeStateConsistent) - InvalidateMeasure(InvalidationTrigger.RendererReady); + InvalidateMeasureInternal(InvalidationTrigger.RendererReady); OnIsPlatformEnabledChanged(); } @@ -428,7 +429,7 @@ public ResourceDictionary Resources void IVisualElementController.NativeSizeChanged() { - InvalidateMeasure(InvalidationTrigger.MeasureChanged); + InvalidateMeasureInternal(InvalidationTrigger.MeasureChanged); } public event EventHandler ChildrenReordered; @@ -559,9 +560,9 @@ public void Unfocus() public event EventHandler Unfocused; - protected virtual void InvalidateMeasure() + protected virtual void InvalidateMeasureInternal() { - InvalidateMeasure(InvalidationTrigger.MeasureChanged); + InvalidateMeasureInternal(InvalidationTrigger.MeasureChanged); } protected override void OnChildAdded(Element child) @@ -647,12 +648,17 @@ internal virtual void ComputeConstraintForView(View view) internal event EventHandler FocusChangeRequested; - internal virtual void InvalidateMeasure(InvalidationTrigger trigger) + internal virtual void InvalidateMeasureInternal(InvalidationTrigger trigger) { _measureCache.Clear(); MeasureInvalidated?.Invoke(this, new InvalidationEventArgs(trigger)); } + void IVisualElementController.InvalidateMeasure(InvalidationTrigger trigger) + { + InvalidateMeasureInternal(trigger); + } + internal void MockBounds(Rectangle bounds) { _mockX = bounds.X; @@ -672,7 +678,7 @@ internal virtual void OnIsPlatformEnabledChanged() internal virtual void OnIsVisibleChanged(bool oldValue, bool newValue) { - InvalidateMeasure(InvalidationTrigger.Undefined); + InvalidateMeasureInternal(InvalidationTrigger.Undefined); } internal override void OnParentResourcesChanged(IEnumerable> values) @@ -746,7 +752,7 @@ static void OnRequestChanged(BindableObject bindable, object oldvalue, object ne } element.SelfConstraint = constraint; - ((VisualElement)bindable).InvalidateMeasure(InvalidationTrigger.SizeRequestChanged); + ((VisualElement)bindable).InvalidateMeasureInternal(InvalidationTrigger.SizeRequestChanged); } void OnUnfocus() diff --git a/Xamarin.Forms.Core/Xamarin.Forms.Core.csproj b/Xamarin.Forms.Core/Xamarin.Forms.Core.csproj index 1deca238e9f..24160a5327d 100644 --- a/Xamarin.Forms.Core/Xamarin.Forms.Core.csproj +++ b/Xamarin.Forms.Core/Xamarin.Forms.Core.csproj @@ -126,7 +126,7 @@ - + diff --git a/Xamarin.Forms.Platform.Android/NativeViewWrapperRenderer.cs b/Xamarin.Forms.Platform.Android/NativeViewWrapperRenderer.cs index 49abc02add0..2036e4bbaca 100644 --- a/Xamarin.Forms.Platform.Android/NativeViewWrapperRenderer.cs +++ b/Xamarin.Forms.Platform.Android/NativeViewWrapperRenderer.cs @@ -1,3 +1,5 @@ +using Xamarin.Forms.Internals; + namespace Xamarin.Forms.Platform.Android { public class NativeViewWrapperRenderer : ViewRenderer @@ -22,7 +24,7 @@ protected override void OnElementChanged(ElementChangedEventArgs Element?.InvalidateMeasure(InvalidationTrigger.MeasureChanged); + Control.LayoutChange += (sender, args) => ((IVisualElementController)Element)?.InvalidateMeasure(InvalidationTrigger.MeasureChanged); } } diff --git a/Xamarin.Forms.Platform.WP8/NativeViewWrapperRenderer.cs b/Xamarin.Forms.Platform.WP8/NativeViewWrapperRenderer.cs index e28dec9441d..e47a6ca0a1d 100644 --- a/Xamarin.Forms.Platform.WP8/NativeViewWrapperRenderer.cs +++ b/Xamarin.Forms.Platform.WP8/NativeViewWrapperRenderer.cs @@ -1,4 +1,5 @@ using System.Windows; +using Xamarin.Forms.Internals; namespace Xamarin.Forms.Platform.WinPhone { @@ -55,7 +56,7 @@ protected override void OnElementChanged(ElementChangedEventArgs { Element?.InvalidateMeasure(InvalidationTrigger.MeasureChanged); }; + Control.LayoutUpdated += (sender, args) => { ((IVisualElementController)Element)?.InvalidateMeasure(InvalidationTrigger.MeasureChanged); }; } } } diff --git a/Xamarin.Forms.Platform.WP8/ProgressBarRenderer.cs b/Xamarin.Forms.Platform.WP8/ProgressBarRenderer.cs index b027d6749e3..293d2d0e4b5 100644 --- a/Xamarin.Forms.Platform.WP8/ProgressBarRenderer.cs +++ b/Xamarin.Forms.Platform.WP8/ProgressBarRenderer.cs @@ -1,5 +1,6 @@ using System.ComponentModel; using System.Windows; +using Xamarin.Forms.Internals; namespace Xamarin.Forms.Platform.WinPhone { @@ -29,7 +30,7 @@ protected override void OnElementPropertyChanged(object sender, PropertyChangedE void ProgressBarOnValueChanged(object sender, RoutedPropertyChangedEventArgs routedPropertyChangedEventArgs) { - Element?.InvalidateMeasure(InvalidationTrigger.MeasureChanged); + ((IVisualElementController)Element)?.InvalidateMeasure(InvalidationTrigger.MeasureChanged); } } } \ No newline at end of file diff --git a/Xamarin.Forms.Platform.WP8/ViewToRendererConverter.cs b/Xamarin.Forms.Platform.WP8/ViewToRendererConverter.cs index 49b232a1408..28f5f8c4934 100644 --- a/Xamarin.Forms.Platform.WP8/ViewToRendererConverter.cs +++ b/Xamarin.Forms.Platform.WP8/ViewToRendererConverter.cs @@ -2,6 +2,7 @@ using System.Globalization; using System.Windows; using System.Windows.Controls; +using Xamarin.Forms.Internals; namespace Xamarin.Forms.Platform.WinPhone { @@ -40,7 +41,7 @@ public WrapperControl(View view) { frameworkElement.Loaded += (sender, args) => { - _view.InvalidateMeasure(InvalidationTrigger.MeasureChanged); + ((IVisualElementController)_view).InvalidateMeasure(InvalidationTrigger.MeasureChanged); InvalidateMeasure(); }; } diff --git a/Xamarin.Forms.Platform.WinRT/DatePickerRenderer.cs b/Xamarin.Forms.Platform.WinRT/DatePickerRenderer.cs index 88df5cbc949..646d7d33a52 100644 --- a/Xamarin.Forms.Platform.WinRT/DatePickerRenderer.cs +++ b/Xamarin.Forms.Platform.WinRT/DatePickerRenderer.cs @@ -3,6 +3,7 @@ using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Media; +using Xamarin.Forms.Internals; #if WINDOWS_UWP @@ -85,12 +86,12 @@ void OnControlDateChanged(object sender, DatePickerValueChangedEventArgs e) if (currentDate != e.NewDate.Date) // Match coerced value UpdateDate(currentDate); - Element.InvalidateMeasure(InvalidationTrigger.SizeRequestChanged); + ((IVisualElementController)Element).InvalidateMeasure(InvalidationTrigger.SizeRequestChanged); } void PickerOnForceInvalidate(object sender, EventArgs eventArgs) { - Element?.InvalidateMeasure(InvalidationTrigger.SizeRequestChanged); + ((IVisualElementController)Element)?.InvalidateMeasure(InvalidationTrigger.SizeRequestChanged); } void UpdateDate(DateTime date) diff --git a/Xamarin.Forms.Platform.WinRT/ImageRenderer.cs b/Xamarin.Forms.Platform.WinRT/ImageRenderer.cs index 29368aaf85e..3807570dbfd 100644 --- a/Xamarin.Forms.Platform.WinRT/ImageRenderer.cs +++ b/Xamarin.Forms.Platform.WinRT/ImageRenderer.cs @@ -3,6 +3,7 @@ using Windows.UI.Xaml; using Windows.UI.Xaml.Media; using Windows.UI.Xaml.Media.Imaging; +using Xamarin.Forms.Internals; #if WINDOWS_UWP @@ -90,7 +91,7 @@ void OnImageOpened(object sender, RoutedEventArgs routedEventArgs) void RefreshImage() { - Element?.InvalidateMeasure(InvalidationTrigger.RendererReady); + ((IVisualElementController)Element)?.InvalidateMeasure(InvalidationTrigger.RendererReady); } void UpdateAspect() diff --git a/Xamarin.Forms.Platform.WinRT/NativeViewWrapperRenderer.cs b/Xamarin.Forms.Platform.WinRT/NativeViewWrapperRenderer.cs index 0e66977468c..b7e70d0f7aa 100644 --- a/Xamarin.Forms.Platform.WinRT/NativeViewWrapperRenderer.cs +++ b/Xamarin.Forms.Platform.WinRT/NativeViewWrapperRenderer.cs @@ -1,4 +1,5 @@ using Windows.UI.Xaml; +using Xamarin.Forms.Internals; #if WINDOWS_UWP @@ -67,7 +68,7 @@ protected override void OnElementChanged(ElementChangedEventArgs { Element?.InvalidateMeasure(InvalidationTrigger.MeasureChanged); }; + Control.LayoutUpdated += (sender, args) => { ((IVisualElementController)Element)?.InvalidateMeasure(InvalidationTrigger.MeasureChanged); }; } } } diff --git a/Xamarin.Forms.Platform.WinRT/PickerRenderer.cs b/Xamarin.Forms.Platform.WinRT/PickerRenderer.cs index e37b79a1931..7095333a64f 100644 --- a/Xamarin.Forms.Platform.WinRT/PickerRenderer.cs +++ b/Xamarin.Forms.Platform.WinRT/PickerRenderer.cs @@ -5,6 +5,7 @@ using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Media; +using Xamarin.Forms.Internals; #if WINDOWS_UWP @@ -97,7 +98,7 @@ void ControlOnOpenAnimationCompleted(object sender, EventArgs eventArgs) if (!Control.IsFullScreen) { // Force a final redraw after the closing animation has completed - Element?.InvalidateMeasure(InvalidationTrigger.MeasureChanged); + ((IVisualElementController)Element)?.InvalidateMeasure(InvalidationTrigger.MeasureChanged); } } @@ -119,7 +120,7 @@ void OnDropDownOpenStateChanged(object sender, object o) } else { - Element?.InvalidateMeasure(InvalidationTrigger.MeasureChanged); + ((IVisualElementController)Element)?.InvalidateMeasure(InvalidationTrigger.MeasureChanged); } } else @@ -127,7 +128,7 @@ void OnDropDownOpenStateChanged(object sender, object o) // The ComboBox is now closed; if we were animating the closure, stop _isAnimating = false; // and force the final redraw - Element?.InvalidateMeasure(InvalidationTrigger.MeasureChanged); + ((IVisualElementController)Element)?.InvalidateMeasure(InvalidationTrigger.MeasureChanged); } } @@ -144,7 +145,7 @@ void StartAnimationRefresh() while (_isAnimating) { await Task.Delay(16); - await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => Element?.InvalidateMeasure(InvalidationTrigger.MeasureChanged)); + await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => ((IVisualElementController)Element)?.InvalidateMeasure(InvalidationTrigger.MeasureChanged)); } }); } diff --git a/Xamarin.Forms.Platform.WinRT/ProgressBarRenderer.cs b/Xamarin.Forms.Platform.WinRT/ProgressBarRenderer.cs index 87f1e35e98e..b805b2f6e1c 100644 --- a/Xamarin.Forms.Platform.WinRT/ProgressBarRenderer.cs +++ b/Xamarin.Forms.Platform.WinRT/ProgressBarRenderer.cs @@ -1,5 +1,6 @@ using System.ComponentModel; using Windows.UI.Xaml.Controls.Primitives; +using Xamarin.Forms.Internals; #if WINDOWS_UWP @@ -53,7 +54,7 @@ protected override void OnElementPropertyChanged(object sender, PropertyChangedE void ProgressBarOnValueChanged(object sender, RangeBaseValueChangedEventArgs rangeBaseValueChangedEventArgs) { - Element?.InvalidateMeasure(InvalidationTrigger.MeasureChanged); + ((IVisualElementController)Element)?.InvalidateMeasure(InvalidationTrigger.MeasureChanged); } } } \ No newline at end of file diff --git a/Xamarin.Forms.Platform.WinRT/TimePickerRenderer.cs b/Xamarin.Forms.Platform.WinRT/TimePickerRenderer.cs index 8c878b29ac0..0095cdc4a77 100644 --- a/Xamarin.Forms.Platform.WinRT/TimePickerRenderer.cs +++ b/Xamarin.Forms.Platform.WinRT/TimePickerRenderer.cs @@ -3,6 +3,7 @@ using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Media; +using Xamarin.Forms.Internals; #if WINDOWS_UWP @@ -77,12 +78,12 @@ protected override void OnElementPropertyChanged(object sender, PropertyChangedE void OnControlTimeChanged(object sender, TimePickerValueChangedEventArgs e) { Element.Time = e.NewTime; - Element?.InvalidateMeasure(InvalidationTrigger.SizeRequestChanged); + ((IVisualElementController)Element)?.InvalidateMeasure(InvalidationTrigger.SizeRequestChanged); } void PickerOnForceInvalidate(object sender, EventArgs eventArgs) { - Element?.InvalidateMeasure(InvalidationTrigger.SizeRequestChanged); + ((IVisualElementController)Element)?.InvalidateMeasure(InvalidationTrigger.SizeRequestChanged); } void UpdateTime() diff --git a/Xamarin.Forms.Platform.iOS/NativeViewWrapperRenderer.cs b/Xamarin.Forms.Platform.iOS/NativeViewWrapperRenderer.cs index b21c859331b..58cacdc624d 100644 --- a/Xamarin.Forms.Platform.iOS/NativeViewWrapperRenderer.cs +++ b/Xamarin.Forms.Platform.iOS/NativeViewWrapperRenderer.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using Xamarin.Forms.Internals; #if __UNIFIED__ using CoreGraphics; using UIKit; @@ -33,7 +34,7 @@ public override void LayoutSubviews() { if (Element?.LayoutSubViews == null) { - Element?.InvalidateMeasure(InvalidationTrigger.MeasureChanged); + ((IVisualElementController)Element)?.InvalidateMeasure(InvalidationTrigger.MeasureChanged); base.LayoutSubviews(); return; } diff --git a/docs/Xamarin.Forms.Core/Xamarin.Forms.Internals/InvalidationTrigger.xml b/docs/Xamarin.Forms.Core/Xamarin.Forms.Internals/InvalidationTrigger.xml new file mode 100644 index 00000000000..345d841a154 --- /dev/null +++ b/docs/Xamarin.Forms.Core/Xamarin.Forms.Internals/InvalidationTrigger.xml @@ -0,0 +1,120 @@ + + + + + Xamarin.Forms.Core + 2.0.0.0 + + + System.Enum + + + + System.Flags + + + + To be added. + To be added. + + + + + + Field + + 2.0.0.0 + + + Xamarin.Forms.Internals.InvalidationTrigger + + + To be added. + + + + + + Field + + 2.0.0.0 + + + Xamarin.Forms.Internals.InvalidationTrigger + + + To be added. + + + + + + Field + + 2.0.0.0 + + + Xamarin.Forms.Internals.InvalidationTrigger + + + To be added. + + + + + + Field + + 2.0.0.0 + + + Xamarin.Forms.Internals.InvalidationTrigger + + + To be added. + + + + + + Field + + 2.0.0.0 + + + Xamarin.Forms.Internals.InvalidationTrigger + + + To be added. + + + + + + Field + + 2.0.0.0 + + + Xamarin.Forms.Internals.InvalidationTrigger + + + To be added. + + + + + + Field + + 2.0.0.0 + + + Xamarin.Forms.Internals.InvalidationTrigger + + + To be added. + + + + diff --git a/docs/Xamarin.Forms.Core/Xamarin.Forms/IVisualElementController.xml b/docs/Xamarin.Forms.Core/Xamarin.Forms/IVisualElementController.xml index a2b63a36d6c..0b465dc236a 100644 --- a/docs/Xamarin.Forms.Core/Xamarin.Forms/IVisualElementController.xml +++ b/docs/Xamarin.Forms.Core/Xamarin.Forms/IVisualElementController.xml @@ -18,6 +18,25 @@ To be added. + + + + Method + + 2.0.0.0 + + + System.Void + + + + + + To be added. + To be added. + To be added. + + diff --git a/docs/Xamarin.Forms.Core/Xamarin.Forms/InvalidationTrigger.xml b/docs/Xamarin.Forms.Core/Xamarin.Forms/InvalidationTrigger.xml new file mode 100644 index 00000000000..b75a5a71b90 --- /dev/null +++ b/docs/Xamarin.Forms.Core/Xamarin.Forms/InvalidationTrigger.xml @@ -0,0 +1,120 @@ + + + + + Xamarin.Forms.Core + 2.0.0.0 + + + System.Enum + + + + System.Flags + + + + To be added. + To be added. + + + + + + Field + + 2.0.0.0 + + + Xamarin.Forms.InvalidationTrigger + + + To be added. + + + + + + Field + + 2.0.0.0 + + + Xamarin.Forms.InvalidationTrigger + + + To be added. + + + + + + Field + + 2.0.0.0 + + + Xamarin.Forms.InvalidationTrigger + + + To be added. + + + + + + Field + + 2.0.0.0 + + + Xamarin.Forms.InvalidationTrigger + + + To be added. + + + + + + Field + + 2.0.0.0 + + + Xamarin.Forms.InvalidationTrigger + + + To be added. + + + + + + Field + + 2.0.0.0 + + + Xamarin.Forms.InvalidationTrigger + + + To be added. + + + + + + Field + + 2.0.0.0 + + + Xamarin.Forms.InvalidationTrigger + + + To be added. + + + + diff --git a/docs/Xamarin.Forms.Core/Xamarin.Forms/VisualElement.xml b/docs/Xamarin.Forms.Core/Xamarin.Forms/VisualElement.xml index bd8e615bd70..732f2d0047c 100644 --- a/docs/Xamarin.Forms.Core/Xamarin.Forms/VisualElement.xml +++ b/docs/Xamarin.Forms.Core/Xamarin.Forms/VisualElement.xml @@ -512,7 +512,6 @@ 1.3.0.0 1.4.0.0 1.5.0.0 - 2.0.0.0 System.Void @@ -523,6 +522,22 @@ To be added. + + + + Method + + 2.0.0.0 + + + System.Void + + + + To be added. + To be added. + + @@ -1829,6 +1844,25 @@ The x value of an element is set during the Layout phase. + + + + Method + + 2.0.0.0 + + + System.Void + + + + + + To be added. + To be added. + To be added. + +