protected override global::Windows.Foundation.Size MeasureOverride(global::Windows.Foundation.Size availableSize) { Size request = _view.Measure(availableSize.Width, availableSize.Height, MeasureFlags.IncludeMargins).Request; if (request.Height < 0) { request.Height = availableSize.Height; } global::Windows.Foundation.Size result; if (_view.HorizontalOptions.Alignment == LayoutAlignment.Fill && !double.IsInfinity(availableSize.Width) && availableSize.Width != 0) { result = new global::Windows.Foundation.Size(availableSize.Width, request.Height); } else { result = new global::Windows.Foundation.Size(request.Width, request.Height); } Layout.LayoutChildIntoBoundingRegion(_view, new Rectangle(0, 0, result.Width, result.Height)); FrameworkElement?.Measure(availableSize); return(result); }
//TODO: We need to revisit this later when we complete the UI Tests for UWP. // Changing the AutomationPeer here prevents the Narrator from functioning properly. // Oddly, it affects more than just the TextBlocks. It seems to break the entire scan mode. //protected override AutomationPeer OnCreateAutomationPeer() //{ // // We need an automation peer so we can interact with this in automated tests // if (Control == null) // { // return new FrameworkElementAutomationPeer(this); // } // return new TextBlockAutomationPeer(Control); //} protected override global::Windows.Foundation.Size ArrangeOverride(global::Windows.Foundation.Size finalSize) { if (Element == null) { return(finalSize); } double childHeight = Math.Max(0, Math.Min(Element.Height, Control.DesiredSize.Height)); var rect = new Rect(); switch (Element.VerticalTextAlignment) { case TextAlignment.Start: break; default: case TextAlignment.Center: rect.Y = (int)((finalSize.Height - childHeight) / 2); break; case TextAlignment.End: rect.Y = finalSize.Height - childHeight; break; } rect.Height = childHeight; rect.Width = finalSize.Width; Control.Arrange(rect); Control.RecalculateSpanPositions(Element, _inlineHeights); return(finalSize); }
protected override global::Windows.Foundation.Size MeasureOverride(global::Windows.Foundation.Size availableSize) { _textBlock.Measure(availableSize); // This deliberately does something wrong so we can demo fixing it Rect bounds = ApplicationView.GetForCurrentView().VisibleBounds; double scaleFactor = DisplayInformation.GetForCurrentView().RawPixelsPerViewPixel; var size = new Size(bounds.Width * scaleFactor, bounds.Height * scaleFactor); return(new global::Windows.Foundation.Size(size.Width, _textBlock.DesiredSize.Height)); }
protected override global::Windows.Foundation.Size MeasureOverride(global::Windows.Foundation.Size availableSize) { if (Element == null) { return(new global::Windows.Foundation.Size(0, 0)); } double width = Math.Max(0, Element.Width); double height = Math.Max(0, Element.Height); var result = new global::Windows.Foundation.Size(width, height); Control?.Measure(result); return(result); }
protected override global::Windows.Foundation.Size ArrangeOverride(global::Windows.Foundation.Size finalSize) { if (Element == null) { return(finalSize); } Element.IsInNativeLayout = true; Control?.Arrange(new Rect(0, 0, finalSize.Width, finalSize.Height)); Element.IsInNativeLayout = false; return(finalSize); }
public virtual SizeRequest GetDesiredSize(double widthConstraint, double heightConstraint) { if (Children.Count == 0 || Control == null) { return(new SizeRequest()); } var constraint = new global::Windows.Foundation.Size(widthConstraint, heightConstraint); TNativeElement child = Control; child.Measure(constraint); var result = new Size(Math.Ceiling(child.DesiredSize.Width), Math.Ceiling(child.DesiredSize.Height)); return(new SizeRequest(result)); }
protected override global::Windows.Foundation.Size ArrangeOverride(global::Windows.Foundation.Size finalSize) { _view.IsInNativeLayout = true; Layout.LayoutChildIntoBoundingRegion(_view, new Rectangle(0, 0, finalSize.Width, finalSize.Height)); if (_view.Width <= 0 || _view.Height <= 0) { // Hide Panel when size _view is empty. // It is necessary that this element does not overlap other elements when it should be hidden. Opacity = 0; } else { Opacity = 1; FrameworkElement?.Arrange(new Rect(_view.X, _view.Y, _view.Width, _view.Height)); } _view.IsInNativeLayout = false; return(finalSize); }
protected override global::Windows.Foundation.Size ArrangeOverride(global::Windows.Foundation.Size finalSize) { _textBlock.Arrange(new Rect(0, 0, finalSize.Width, finalSize.Height)); return(finalSize); }