Xamarin - Load Frame with Image inside a Contentview

Asked

Viewed 223 times

1

I want to change this Sketch so I can draw in a photo. I lowered the github and I’m making the modifications.

However, I am not able to load an image on the screen when setting the Image Source.

private Grid BuildGrid()
    {
        return new Grid
        {
            VerticalOptions = LayoutOptions.FillAndExpand,
            HorizontalOptions = LayoutOptions.FillAndExpand,
            RowDefinitions = {
                new RowDefinition {
                    Height = GridLength.Auto
                },
                new RowDefinition {
                    Height = new GridLength (1, GridUnitType.Star)
                },
            },
            ColumnDefinitions = {
                new ColumnDefinition {
                    Width = new GridLength (100, GridUnitType.Absolute)
                },
                new ColumnDefinition {
                    Width = new GridLength (1, GridUnitType.Star)
                },
            },
            Children =
            {
              {new Label {
                    Text = "Sketch",
                    Font = Font.BoldSystemFontOfSize (50),
                    HorizontalOptions = LayoutOptions.CenterAndExpand,
                    VerticalOptions = LayoutOptions.FillAndExpand
                    }, 0, 2, 0, 1},
              {BuildPalletFrame(), 0, 1},
              {new ContentView {
                   Content = BuildDrawingFrame(),
                   Padding = new Thickness(10, 0, 0, 0),
                   HorizontalOptions = LayoutOptions.FillAndExpand,
                   VerticalOptions = LayoutOptions.FillAndExpand,
              }, 1, 1}
            }
        };
    }

private Frame BuildDrawingFrame()
    {

        DrawingImage = new ImageWithTouch
        {
            VerticalOptions = LayoutOptions.FillAndExpand,
            HorizontalOptions = LayoutOptions.FillAndExpand,
            BackgroundColor = Color.Transparent,
            CurrentLineColor = Color.Black,
            Source  = "imagem.png"       // <<----------
        };

        DrawingImage.SetBinding(ImageWithTouch.CurrentLineColorProperty, "CurrentLineColor");

        var palleteFrame = new Frame
        {
            BackgroundColor = Color.Transparent,
            Padding = 5,
            HasShadow = true,
            OutlineColor = Color.Black,
            Content = DrawingImage
        };

        return palleteFrame;
    }
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.