protected override void OnElementChanged(ElementChangedEventArgs <ImageButton> e) { if (Control == null) { SetNativeControl(new Box(System.Maui.Maui.NativeParent)); Control.SetLayoutCallback(OnLayout); _round = new Native.RoundRectangle(System.Maui.Maui.NativeParent); _round.Show(); _border = new Native.BorderRectangle(System.Maui.Maui.NativeParent); _border.Show(); _image = new Native.Image(System.Maui.Maui.NativeParent); _image.Show(); _button = new EButton(System.Maui.Maui.NativeParent) { Style = "transparent" }; _button.Clicked += OnClicked; _button.Pressed += OnPressed; _button.Released += OnReleased; _button.Show(); Control.PackEnd(_round); Control.PackEnd(_image); Control.PackEnd(_border); Control.PackEnd(_button); } base.OnElementChanged(e); }
EvasObject GetContent(object data, string part) { ShellSection section = data as ShellSection; var box = new Native.Box(System.Maui.Maui.NativeParent); box.Show(); var icon = new Native.Image(System.Maui.Maui.NativeParent) { MinimumWidth = System.Maui.Maui.ConvertToScaledPixel(44), MinimumHeight = System.Maui.Maui.ConvertToScaledPixel(27) }; var task = icon.LoadFromImageSourceAsync(section.Icon); icon.Show(); var title = new Native.Label(System.Maui.Maui.NativeParent) { Text = section.Title, FontSize = System.Maui.Maui.ConvertToEflFontPoint(14), HorizontalTextAlignment = Native.TextAlignment.Start, VerticalTextAlignment = Native.TextAlignment.Center }; title.Show(); box.PackEnd(icon); box.PackEnd(title); box.LayoutUpdated += (object sender, LayoutEventArgs e) => { icon.Move(e.Geometry.X + _iconPadding, e.Geometry.Y + _iconPadding); icon.Resize(_iconSize, _iconSize); title.Move(e.Geometry.X + 2 * _iconPadding + _iconSize, e.Geometry.Y); title.Resize(e.Geometry.Width - (2 * _iconPadding + _iconSize), e.Geometry.Height); }; box.MinimumHeight = _cellHeight; return(box); }