Try the following snippet that uses the RemoveAt method of the AbsoluteLayout.Children collection.
Alternatively you can use the Remove(View) method if you have a variable reference.
StackLayout objStackLayout = new StackLayout()
{
};
//
AbsoluteLayout objAbsoluteLayout = new AbsoluteLayout()
{
};
//
BoxView objBox1 = new BoxView()
{
Color = Color.Red,
WidthRequest = 50,
HeightRequest = 50,
};
objAbsoluteLayout.Children.Add(objBox1, new Point(100,100));
System.Diagnostics.Debug.WriteLine("Children Count : " + objAbsoluteLayout.Children.Count);
//
BoxView objBox2 = new BoxView()
{
Color = Color.Green,
WidthRequest = 50,
HeightRequest = 50,
};
objAbsoluteLayout.Children.Add(objBox2, new Point(200, 200));
System.Diagnostics.Debug.WriteLine("Children Count : " + objAbsoluteLayout.Children.Count);
//
Button objButton1 = new Button()
{
Text = "Remove First Child"
};
objButton1.Clicked += ((o2, e2) =>
{
if (objAbsoluteLayout.Children.Count > 0)
{
// To Remove a View at a specific index use:-
objAbsoluteLayout.Children.RemoveAt(0);
//
DisplayAlert("Children Count", objAbsoluteLayout.Children.Count.ToString(), "OK");
}
else
{
DisplayAlert("Invalid", "There are no more children that can be removed", "OK");
}
});
//
objStackLayout.Children.Add(objAbsoluteLayout);
objStackLayout.Children.Add(objButton1);