Removing Childs from a stacklayout

15mgm1515mgm15 USMember ✭✭✭✭

Hello

How can I remove a stacklayout when an image is clicked:

Image chooseUser = new Image
            {
                //Source = ImageSource.FromFile("chosseUser.png"),
                BackgroundColor = Color.White,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions = LayoutOptions.FillAndExpand
            };
            mainStackLayOut.Children.Add(chooseUser);

            var profileTapRecognizer = new TapGestureRecognizer
            {
                TappedCallback = (v, o) =>
                {
                    Console.WriteLine("Image clicked "); **//Remove (chooseUser )**

                },
                NumberOfTapsRequired = 1
            };

            Image doctorImage = new Image
            {
                WidthRequest = buttonWidth,
                HeightRequest = buttonHeight,
                BackgroundColor = Color.Gray,
                Source = ImageSource.FromFile ("about.png")

            };
            doctorImage.GestureRecognizers.Add(profileTapRecognizer);
            buttonsStackLayOut.Children.Add(doctorImage);

Posts

  • JasonAwbreyJasonAwbrey USInsider, University, Developer Group Leader mod

    Children.Remove or Children.RemoveAt

  • 15mgm1515mgm15 USMember ✭✭✭✭

    Excellent, Thanks!

  • HayHay USMember ✭✭

    Anyone with the idea to hide a StackLayout from a XAML form?

    The use of isVisible=False leaves a huge space over the controls beneath but i want a removal of the stakLayout and closeup of the space created

    Thanks

  • Emixam23Emixam23 USMember ✭✭✭

    Opacity="0" ?

Sign In or Register to comment.