I have problem with putting long text into Label which is enclosed in ScrollView in Xamarin.Forms
I have something like this:
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<ScrollView Grid.Row="0">
<customControls:Label x:Name="Text" />
</ScrollView>
<StackLayout Grid.Row="1">
<Button Text="Cancel" Command="{Binding CancelCommand}" HorizontalOptions="Start" VerticalOptions="Center"></Button>
<Button Text="Accept" Command="{Binding ShowSignatureCommand}" HorizontalOptions="End" VerticalOptions="Center" />
</StackLayout>
</Grid>
And result is:

It seems, that ScrollViewer does not hide stuff, which does not fit in it.
I have also tried with StackLayout, but same result.
How should I handle that?
As I know it might happens when if you not define columns inside Grid. There are lots of way to do what you want:
With using Grid:
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="70"/>
<ColumnDefinition Width="70"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<ScrollView Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="4">
<yourControl/>
</ScrollView>
<Button Grid.Row="1" Grid.Column="1" Text="Ok" />
<Button Grid.Row="1" Grid.Column="2" Text="Cancel" />
</Grid>
With using StackLayout:
<StackLayout>
<ScrollView VerticalOptions="Fill">
<yourViewController/>
</ScrollView>
<StackLayout HorizontalOptions="Center" Orientation="Horizontal" Spacing="5">
<Button Text="Ok"/>
<Button Text="Cancel"/>
</StackLayout>
</StackLayout>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With