protected override EvasObject OnGetContent(Cell cell, string part) { if (part == ImagePart) { var imgCell = cell as ImageCell; int pixelSize = Forms.ConvertToScaledPixel(imgCell.RenderHeight); if (pixelSize <= 0) { pixelSize = Forms.ConvertToPixel(_defaultHeight); } var image = new Native.Image(Forms.NativeParent) { MinimumWidth = pixelSize, MinimumHeight = pixelSize }; image.SetAlignment(-1.0, -1.0); // fill image.SetWeight(1.0, 1.0); // expand var task = image.LoadFromImageSourceAsync(imgCell.ImageSource); return(image); } else { return(null); } }
protected override EvasObject OnGetContent(Cell cell, string part) { if (part == MainContentPart) { var entryCell = cell as EntryCell; int pixelHeight = Forms.ConvertToScaledPixel(entryCell.RenderHeight); pixelHeight = pixelHeight > 0 ? pixelHeight : Forms.ConvertToPixel(s_defaultHeight); var label = new Label() { HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.Center, VerticalTextAlignment = TextAlignment.Center, FontSize = -1 }; label.SetBinding(Label.TextProperty, new Binding(EntryCell.LabelProperty.PropertyName)); label.SetBinding(Label.TextColorProperty, new Binding(EntryCell.LabelColorProperty.PropertyName, converter: new DefaultColorConverter())); var entry = new Entry() { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.Center, FontSize = -1, }; entry.SetBinding(Entry.TextProperty, new Binding(EntryCell.TextProperty.PropertyName, BindingMode.TwoWay)); entry.SetBinding(Entry.PlaceholderProperty, new Binding(EntryCell.PlaceholderProperty.PropertyName)); entry.SetBinding(InputView.KeyboardProperty, new Binding(EntryCell.KeyboardProperty.PropertyName)); entry.SetBinding(Entry.HorizontalTextAlignmentProperty, new Binding(EntryCell.HorizontalTextAlignmentProperty.PropertyName)); var layout = new StackLayout() { Orientation = StackOrientation.Horizontal, Children = { label, entry } }; layout.Parent = cell; layout.BindingContext = entryCell; layout.MinimumHeightRequest = Forms.ConvertToScaledDP(pixelHeight); var renderer = Platform.GetOrCreateRenderer(layout); (renderer as LayoutRenderer)?.RegisterOnLayoutUpdated(); var nativeView = renderer.NativeView; nativeView.PropagateEvents = false; nativeView.MinimumHeight = pixelHeight; _cacheCandidate[nativeView] = layout; nativeView.Deleted += (sender, e) => { _cacheCandidate.Remove(sender as EvasObject); }; return(nativeView); } return(null); }
protected override EvasObject OnReusableContent(Cell cell, string part, EvasObject old) { if (!_cacheCandidate.ContainsKey(old)) { return(null); } var layout = _cacheCandidate[old]; layout.BindingContext = cell; int height = Forms.ConvertToScaledPixel(cell.RenderHeight); height = height > 0 ? height : Forms.ConvertToPixel(s_defaultHeight); old.MinimumHeight = height; return(old); }
static double CalculateDoubleScaledSizeInLargeScreen(double size) { if (Forms.DisplayResolutionUnit.UseVP) { return(size); } if (!Forms.DisplayResolutionUnit.UseDeviceScale && GetPhysicalPortraitSizeInDP() > 1000) { size *= 2.5; } if (!Forms.DisplayResolutionUnit.UseDP) { size = Forms.ConvertToPixel(size); } return(size); }