LHS
LHS

Reputation: 21

xamarin - need help forcing the scrollview width to fill the entire width of the frame

I have a page that has sectioned data in separate frames.

within the frames, i have a scrollview and within the scrollview a stacklayout vertical, a label and then i have either a gridview or a datagrid with information in it. something like this:

<frame Padding="5,5,5,5" Margin="5,5,5,5" BackgroundColor="{StaticResource purple}" IsVisible="{Binding IsVisibleClientInfo}">
    <scrollview Orientation="Horizontal" HorizontalOptions="FillAndExpand">
        <stacklayout vertical>
           <label for title />
           <grid>
           </grid>
        </stacklayout>
    </scrollview>
</frame>

example below: this is what the 'page looks like' i cannot seem to get the scrollview/label/data components to fill the space so that i have a nice clean frame.

edit: i have fiddled with everything from isclippedtobounds, the column widths, etc. I am still left with a large purple gap on the right side of the frame and nothing i do to any of the components within the frame seem to force the scrollview to expand to fill the entire frame. This is what i need help on. How can i force the scrollview to fill the entire frame?

Upvotes: 2

Views: 2296

Answers (2)

Doğukan Şeng&#252;l
Doğukan Şeng&#252;l

Reputation: 11

I had a similar problem with my scroll view. The problem was caused by the absolute layout. My scroll view was in an absolute layout. However in an absolute layout, you have to explicitly set layout bounds, otherwise child elements won't size properly. So my solution was wrapping the scroll view in a stack layout and setting layout bounds for stack layout.

Upvotes: 1

jbtamares
jbtamares

Reputation: 778

I tried to replicate your xaml modifying the ScrollView a bit, by inserting a Margin="1" though this shouldn't make a big difference with what you have. As for my end, it's working as intended, so maybe you could try it out:

<Frame Padding="0" Margin="0" BackgroundColor="Purple">
    <ScrollView Margin="1" Orientation="Horizontal" HorizontalOptions="FillAndExpand"
                VerticalOptions="FillAndExpand" BackgroundColor="White">
        <StackLayout Orientation="Vertical" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
            <Label Text="TEST"/>
        </StackLayout>
    </ScrollView>
</Frame>

Below is the result:

result

Upvotes: 0

Related Questions