-1

enter image description here

I have a button within my CollectionView Footer that reaches the ends of the screen horizontally. I want to be able to set the width either to the size of the text, or to a width I pick.

Changing HorizontalOptions does nothing. I've been messing around with :

  • WidthRequest
  • MinimumWidthRequest
  • HeightRequest
  • MinimumHeightRequest

These options only affect button height.

Bas H
  • 2,114
  • 10
  • 14
  • 23
RonnieG
  • 21
  • 3
  • **Show the code** that you wrote, which results in that symptom. – ToolmakerSteve Dec 18 '21 at 21:53
  • 1
    use `WidthRequest`. But without knowing anything about your layout it's impossible to say why that's not working. As @ToolmakerSteve suggests, you need to post the relevant code. Please read [ask] for more guidance on writing a good question – Jason Dec 18 '21 at 22:08
  • Does this answer your question? [How to resize a button in Xamarin](https://stackoverflow.com/questions/39769793/how-to-resize-a-button-in-xamarin). Found this and similar answers by google `xamarin forms button widthrequest has no effect`. – ToolmakerSteve Dec 18 '21 at 22:26

1 Answers1

0

As a workaround, you can set a grid in footer, then set the width and height of grid ,code like:

<CollectionView.Footer>
//width&height
<Grid ColumnDefinitions="*,100,*"
RowDefinitions="50">
<Button Grid.Column="1",Text="Click" BackgroundColor="Red"/>
</Grid>
</CollectionView.Footer>
Adrain
  • 1,946
  • 1
  • 3
  • 7