Ejemplo n.º 1
0
 void FillContent()
 {
     _scrollCanvas.UnPackAll();
     if (Element.Content != null)
     {
         _scrollCanvas.PackEnd(Platform.GetOrCreateRenderer(Element.Content).NativeView);
         UpdateContentSize();
     }
 }
Ejemplo n.º 2
0
        void Initialize(EvasObject parent)
        {
            _box = new Native.Box(parent)
            {
                AlignmentX = -1,
                AlignmentY = -1,
                WeightX    = 1,
                WeightY    = 1
            };
            SetContent(_box);

            _menu = new GenList(parent)
            {
                BackgroundColor = EColor.Transparent,
                Style           = "solid/default",
            };

            _menu.ItemSelected += (s, e) =>
            {
                _flyoutMenu.TryGetValue(e.Item.Data as Item, out Element element);

                SelectedItemChanged?.Invoke(this, new SelectedItemChangedEventArgs(element, -1));
            };

            _menu.Show();
            _box.PackEnd(_menu);

            _defaultClass = new GenItemClass("double_label")
            {
                GetTextHandler = (obj, part) =>
                {
                    if (part == "elm.text")
                    {
                        return(((Item)obj).Title);
                    }
                    else
                    {
                        return(null);
                    }
                },
                GetContentHandler = (obj, part) =>
                {
                    if (part == "elm.swallow.icon")
                    {
                        var icon = ((Item)obj).Icon;
                        if (icon != null)
                        {
                            var image = new Native.Image(parent)
                            {
                                MinimumWidth  = System.Maui.Maui.ConvertToScaledPixel(24),
                                MinimumHeight = System.Maui.Maui.ConvertToScaledPixel(24)
                            };
                            var result = image.LoadFromImageSourceAsync(icon);
                            return(image);
                        }
                        else
                        {
                            return(null);
                        }
                    }
                    else
                    {
                        return(null);
                    }
                }
            };
        }