【发布时间】:2018-11-01 15:22:16
【问题描述】:
我想要这样的结构: Click this to see the desired output
但是使用我的代码,我得到了这个:Click this to see the output
这是我的 xaml 代码:
<ScrollView Orientation="Horizontal">
<StackLayout Orientation="Horizontal" VerticalOptions="Start">
<Grid x:Name="ImagesListViews" >
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
</Grid>
<local:BindableStackLayout x:Name="featuredEventsList">
<local:BindableStackLayout.ItemDataTemplate>
<DataTemplate>
<StackLayout Orientation="Vertical" Padding="0" Margin="-5,0,5,0" HorizontalOptions="Center" >
<StackLayout.GestureRecognizers>
<TapGestureRecognizer NumberOfTapsRequired="1" />
</StackLayout.GestureRecognizers>
<Image Source="{Binding ImageThumbURL}" Margin="0,0,0,0" WidthRequest="140" />
<Label Margin="0" Text="{Binding TitleInPrimaryLang}" FontSize="12" TextColor="Black" LineBreakMode="TailTruncation" WidthRequest="100"/>
</StackLayout>
</DataTemplate>
</local:BindableStackLayout.ItemDataTemplate>
</local:BindableStackLayout>
</StackLayout>
</ScrollView>
任何帮助将不胜感激。谢谢
【问题讨论】:
-
你有什么理由在stacklayout中放置一个空网格吗?
-
正如 Depechie 提到的,在这个 xaml 中名为 ImagesListViews 的网格是空的(也许您已经删除了问题的内容?)。我不确定您对 local:BindableStackLayout 有什么实现,但是您是否尝试过将其 Orientation 设置为水平?
-
@Dev 您是否将您的子视图添加到您的
featuredEventsList中?如果是这样,您需要使其方向水平。另外,你为什么不删除Grid和父Stacklayout,只留下你的BindableStackLayout?
标签: xaml xamarin xamarin.forms