How to make "RefreshView" friends with "AbsoluteLayout"

валера карманов 361 Reputation points
2024-10-08T16:42:53.7533333+00:00
public CollectionPage() : base()
{
	collection.SelectionChanged += _OnSelectionChanged;
	collection.ItemTemplate = GetDataTemplate();

	LoadedCollection();

	refresh.Command = new Command(LoadedCollection);
	refresh.Content = collection;

	var fabButton = new ImageButton {
		Padding = new Thickness(5),
		BackgroundColor = Color.FromRgba("#567ea7"),
		Source = ImageSource.FromFile("add_icon.png"),
		HorizontalOptions = LayoutOptions.Center,
		VerticalOptions = LayoutOptions.Center,
		WidthRequest = 60, HeightRequest = 60
	};

	AbsoluteLayout.SetLayoutBounds(
		fabButton, new Rect(.9, .95, 60, 60)
	);

	AbsoluteLayout.SetLayoutFlags(
		fabButton, AbsoluteLayoutFlags.PositionProportional
	);

	Content = new AbsoluteLayout {
		Children = { refresh, fabButton }
	};
}

I can't display the "RefreshView" element in full size. It seems to me that I need to set the "SetLayoutBounds" and "SetLayoutFlags" properties for "RefreshView" so that this element fills the entire layout size.

The element itself is displayed, but it is somewhere in negative positions.

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,542 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) 31,976 Reputation points Microsoft Vendor
    2024-10-10T09:10:45.2433333+00:00

    Hello,

    After testing, the RefreshView(with Collectionview) will display the full width when changing the Content from AbsoluteLayout to StackLayout.

    Content = new StackLayout
    {
         Children = { refresh, fabBorder }
    };
    

    Best Regards,

    Wenyan Zhang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.