【发布时间】:2020-02-04 20:12:55
【问题描述】:
我在一页上有两个列表视图,但问题是刷新列表视图时只刷新一个列表,滚动列表视图时也滚动一个列表视图,
有关更多信息,我无法将两个列表视图合并为一个,因为我在某些情况下与附件列表视图有关
xaml 代码
<StackLayout>
<ListView x:Name="detailsList" HeightRequest="5000" ItemsSource="{Binding DetailsList}"
IsPullToRefreshEnabled="true" RefreshCommand="{Binding RefreshCommand}">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Orientation="Horizontal" Padding="5">
<StackLayout HorizontalOptions="FillAndExpand">
<es:Label Text="{Binding Value}" VerticalTextAlignment="Center" HorizontalOptions="EndAndExpand" />
<BoxView BackgroundColor="#eeeeee" HeightRequest="2" />
</StackLayout>
<StackLayout Padding="0,0,0,2">
<es:Label Text="{Binding Key}" WidthRequest="100" MinimumWidthRequest="100" TextColor="{Binding Color}"
HorizontalTextAlignment="Start" VerticalTextAlignment="Center" />
</StackLayout>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<ListView x:Name="Attachments" ItemsSource="{Binding Attachments}" SeparatorVisibility="None" BackgroundColor="White" HasUnevenRows="true" SelectionMode="None"
IsPullToRefreshEnabled="false" RefreshCommand="{Binding RefreshCommand}">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell Tapped="Attachment_Tapped">
<StackLayout Orientation="Horizontal" Padding="5">
<StackLayout HorizontalOptions="FillAndExpand">
<es:Label Text="{Binding Value.AttachmentTitle}" VerticalTextAlignment="Center" HorizontalOptions="EndAndExpand"/>
<Image Source="attach.png" HorizontalOptions="EndAndExpand"></Image>
<BoxView BackgroundColor="#eeeeee" HeightRequest="2" />
</StackLayout>
<StackLayout Padding="0,0,0,2">
<es:Label Text="{Binding Key}" WidthRequest="100" MinimumWidthRequest="100" TextColor="{Binding Color}"
HorizontalTextAlignment="Start" VerticalTextAlignment="Center" />
</StackLayout>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
我尝试执行此代码但仍然无法正常工作,我尝试执行ListView.FooterTemplate 但无济于事
<StackLayout>
<ListView x:Name="detailsList" HeightRequest="5000" ItemsSource="{Binding DetailsList}"
IsPullToRefreshEnabled="true" RefreshCommand="{Binding RefreshCommand}">
<ListView.HeaderTemplate>
<DataTemplate>
<ListView x:Name="Attachments" ItemsSource="{Binding Attachments}"
IsPullToRefreshEnabled="false" RefreshCommand="{Binding RefreshCommand}">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell Tapped="Attachment_Tapped">
<StackLayout Orientation="Horizontal" Padding="5">
<StackLayout HorizontalOptions="FillAndExpand">
<es:Label Text="{Binding Value.AttachmentTitle}" VerticalTextAlignment="Center" HorizontalOptions="EndAndExpand"/>
<Image Source="attach.png" HorizontalOptions="EndAndExpand"></Image>
<BoxView BackgroundColor="#eeeeee" HeightRequest="2" />
</StackLayout>
<StackLayout Padding="0,0,0,2">
<es:Label Text="{Binding Key}" WidthRequest="100" MinimumWidthRequest="100" TextColor="{Binding Color}"
HorizontalTextAlignment="Start" VerticalTextAlignment="Center" />
</StackLayout>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</DataTemplate>
</ListView.HeaderTemplate>
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Orientation="Horizontal" Padding="5">
<StackLayout HorizontalOptions="FillAndExpand">
<es:Label Text="{Binding Value}" VerticalTextAlignment="Center" HorizontalOptions="EndAndExpand" />
<BoxView BackgroundColor="#eeeeee" HeightRequest="2" />
</StackLayout>
<StackLayout Padding="0,0,0,2">
<es:Label Text="{Binding Key}" WidthRequest="100" MinimumWidthRequest="100" TextColor="{Binding Color}"
HorizontalTextAlignment="Start" VerticalTextAlignment="Center" />
</StackLayout>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
谢谢你提前:)
【问题讨论】:
-
为什么同一个页面有两个不同的列表?
标签: xamarin xamarin.android xamarin.ios