C# 当应用程序加载时,如何首先显示第一个网格行

C# 当应用程序加载时,如何首先显示第一个网格行,c#,xamarin.forms,C#,Xamarin.forms,我的网格布局似乎是为第一行显示的第二行设置的 当应用程序加载Grid.Row=“2”时,首先显示页面的中间部分。 我必须向下滚动才能看到旋转木马巫婆网格。Row=“1” 我试图找出顶部的旋转木马,然后是视频,最后是更改程序 这是我的xaml代码 <ScrollView HorizontalOptions="Center"> <Grid x:Name="page" Padding="0,0"> <Gr

我的网格布局似乎是为第一行显示的第二行设置的

当应用程序加载Grid.Row=“2”时,首先显示页面的中间部分。 我必须向下滚动才能看到旋转木马巫婆网格。Row=“1” 我试图找出顶部的旋转木马,然后是视频,最后是更改程序

这是我的xaml代码

 <ScrollView HorizontalOptions="Center">
 <Grid x:Name="page" Padding="0,0"> 
 <Grid.RowDefinitions>
 <RowDefinition Height="600" /> 
 <RowDefinition Height="Auto" /> 
 <RowDefinition Height="Auto" />
 </Grid.RowDefinitions>
<StackLayout Grid.Row="0"> 
 <CarouselView x:Name="carousel" Scrolled="Handle_Scrolled" ItemsSource="{Binding Items}" 
  VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand"> 
<CarouselView.Behaviors> 
<behaviors:FrontBannerViewParallaxBehavior ParallaxOffset="100"/> 
</CarouselView.Behaviors>
<CarouselView.ItemTemplate> <DataTemplate> <Grid Padding="18,24,18,64"> <custom:PancakeView 
CornerRadius="24" BackgroundColor="#FFFFFF"> <StackLayout VerticalOptions="Fill"     
HorizontalOptions="Fill"> <custom:PancakeView VerticalOptions="FillAndExpand" HeightRequest="200" 
CornerRadius="10" BackgroundGradientStartColor="{Binding StartColor}"       
BackgroundGradientEndColor="{Binding EndColor}"> <Grid> <StackLayout> <StackLayout 
Orientation="Horizontal"> <Label Text="{Binding Title}" FontFamily="{StaticResource 
font_extrabold}" HorizontalOptions="Center" TextColor="#60229a" VerticalOptions="End" 
 Margin="14,0,0,0" FontSize="36" FontAttributes="Bold" LineBreakMode="NoWrap" /> </StackLayout> 
<Label FontFamily="{StaticResource font_regular}" Text="{Binding Details}" TextColor="#60229a" 
Margin="14,8,24,24" FontSize="22" LineBreakMode="WordWrap" /> </StackLayout> </Grid> 
 </custom:PancakeView> </StackLayout> </custom:PancakeView> <Image Source="{Binding ImageSrc}" 
  WidthRequest="{Binding Width}" VerticalOptions="EndAndExpand" HorizontalOptions="EndAndExpand" 
  Margin="0,0,15,0" /> </Grid> </DataTemplate> </CarouselView.ItemTemplate> 
 </CarouselView> 
 </StackLayout>
 <StackLayout Grid.Row="1">`
       `<StackLayout Orientation="Horizontal">
            <Label Text="Listen to Apostle Johnson's" FontFamily="{StaticResource 
font_extrabold}" HorizontalOptions="Center" TextColor="#FFFFFF" VerticalOptions="End" Margin="14,0,0,0" FontSize="36" FontAttributes="Bold" LineBreakMode="NoWrap" />
        </StackLayout>
        <Label FontFamily="{StaticResource font_regular}"  Text="Detox Transformation." TextColor="#FFFFFF" Margin="14,8,24,24" FontSize="22" LineBreakMode="WordWrap" />
    <StackLayout Orientation="Horizontal">
            <Label FontFamily="{StaticResource font_regular}" Text="Apostle Johnson gives a 
riveting short bio of his testimony of traveling a road of living a life of descriptive chaos.  Hey just click on the video and hear it from him." TextColor="#FFFFFF" Margin="14,8,24,24" FontSize="22" LineBreakMode="WordWrap" />
        </StackLayout>
        <StackLayout Orientation="Horizontal">
            <ovideo:VideoPlayer x:Name="vmo" Source="http://iowegodministry.org/wp-content/uploads/2020/06/y2mate.com-FROM-GANGSTA-TO-GOD_JeR29HVa7HE_360p.mp4" WidthRequest="250" />
        </StackLayout>
    </StackLayout> 
    <StackLayout Grid.Row="2">
        <StackLayout Orientation="Horizontal">
            <Label Text="Chance Program" FontFamily="{StaticResource font_extrabold}" HorizontalOptions="Center" TextColor="#FFFFFF" VerticalOptions="End" Margin="14,0,0,0" FontSize="36" FontAttributes="Bold" LineBreakMode="NoWrap" />
        </StackLayout>
        <Label FontFamily="{StaticResource font_regular}"  Text="The mission of C.H.A.N.C.E. is to help people succeed in the workforce by providing training and mentorship.  One of the goals is to help those who've been in the prison system become successful members of society after they get out.  The program will provide clas`enter code here`ses on a variety of spiritual-based educational curriculum, teach job interview skills, and help with strengthening family relationships and bonds." TextColor="#FFFFFF" Margin="14,8,24,24" FontSize="22" LineBreakMode="WordWrap" />
        <Button BackgroundColor="#FFFFFF" 
                FontFamily="{StaticResource font_bold}" 
                Padding="20,0" CornerRadius="20" 
                TextColor="{Binding BackgroundColor}" 
                FontSize="12" BorderColor="{Binding BackgroundColor}" 
                BorderWidth="2" HeightRequest="40" 
                Text="Read More About the Program" HorizontalOptions="Center" Clicked="OnButtonClicked"
                />
    </StackLayout>
</Grid>
  

   
 </ScrollView>

`
`

来自共享的Xaml代码,使用
ScrollView
作为根布局。ScrollView有一种方法可以滚动到视图中的一个位置。您可以尝试在应用程序加载时滚动到您想要的位置

可以使用接受双
x
y
参数的
ScrollToAsync
方法将
ScrollView
中的位置滚动到

给定名为ScrollView的垂直
ScrollView
对象,以下示例显示如何从
ScrollView
顶部滚动到
150
设备独立单元:

await scrollView.ScrollToAsync(0, 150, true);