- Use VerticalOptions="Left".
Xamarin forms vertical slider
I want a vertical slider placed left of screen.
I use this code :
<Grid x:Name="grdCameraViewer" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
<Slider x:Name="sldCameraZoomValue" Maximum="50.0" Minimum="10.0"
VerticalOptions="Center" HorizontalOptions="FillAndExpand" Margin="0" Rotation="-90" />
</Grid>
it work for vertical slider, but I cannot put it left of screen.it placed center of screen.
2 answers
Sort by: Most helpful
-
PRASANT MOHANTY 1 Reputation point
2021-06-18T09:10:24.357+00:00 -
JessieZhang-MSFT 7,706 Reputation points Microsoft Vendor
2021-06-18T09:56:29.343+00:00 Hello,
Welcome to our Microsoft Q&A platform!
Just change the
HorizontalOptions
of yourGrid
toStart
:<ContentPage.Content> <Grid x:Name="grdCameraViewer" HorizontalOptions="Start" VerticalOptions="FillAndExpand"> <Slider x:Name="sldCameraZoomValue" Maximum="50.0" Minimum="10.0" VerticalOptions="Center" HorizontalOptions="FillAndExpand" Margin="0" Rotation="-90" /> </Grid> </ContentPage.Content>
Note: At this time ,we will find the slider is very small .
As a test, when I increased the width and height as follows:
<Grid x:Name="grdCameraViewer" HorizontalOptions="Start" VerticalOptions="FillAndExpand" BackgroundColor="Gray"> <Slider x:Name="sldCameraZoomValue" Maximum="50.0" Minimum="10.0" WidthRequest="300" HeightRequest="50" BackgroundColor="Yellow" VerticalOptions="Center" HorizontalOptions="FillAndExpand" Margin="0" Rotation="-90" /> </Grid>
The result is:
We will find that as the width and height of the slider increases, so does the distance to the left of the slider.
This means that when the horizontal slider is adjusted to be vertical, the slider still occupies the corresponding width in the horizontal direction.Best Regards,
Jessie Zhang
---
If the response is helpful, please click "Accept Answer" and upvote it.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.