【发布时间】:2019-12-19 07:23:43
【问题描述】:
我在 xamarin 表单中创建了 FlowListView.FlowLoadingTemplate。当点击 FlowItemTappedCommand 时转到另一个页面或导航到另一个页面。
FlowListView xaml:
<StackLayout Padding="10">
<flv:FlowListView FlowColumnCount="2"
x:Name="FlowListView"
SeparatorVisibility="Default"
HasUnevenRows="True"
FlowTappedBackgroundColor="Red" FlowIsLoadingInfiniteEnabled="True"
FlowItemTappedCommand="{Binding ItemTappedCommand}"
FlowItemsSource="{Binding Items}">
<flv:FlowListView.FlowLoadingTemplate>
<DataTemplate>
<ViewCell>
<Label
HorizontalTextAlignment="Center"
VerticalTextAlignment="Center"
TextColor="Black"
Text="Loading..."
></Label>
</ViewCell>
</DataTemplate>
</flv:FlowListView.FlowLoadingTemplate>
<flv:FlowListView.FlowColumnTemplate>
<DataTemplate >
<Grid Padding="5">
<BoxView Color="#121E22" Opacity="0.8" CornerRadius="6" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Grid.Row="0">
</BoxView>
<StackLayout Padding="5" Grid.Row="0">
<ff:CachedImage
HeightRequest="70" WidthRequest="70" Aspect="AspectFill"
HorizontalOptions="Center" VerticalOptions="Center"
DownsampleWidth="70" DownsampleUseDipUnits="true"
Source ="{Binding Icon}" DownsampleToViewSize="True"
LoadingPlaceholder="Spinner.png"
ErrorPlaceholder= "ErrorImage"
CacheDuration= "50"
RetryCount= "3"
RetryDelay= "600"
>
</ff:CachedImage>
<Label Text="{Binding Title}" TextColor="White" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand" HorizontalTextAlignment="Center"/>
</StackLayout>
</Grid>
</DataTemplate>
</flv:FlowListView.FlowColumnTemplate>
</flv:FlowListView>
</StackLayout>
流列表绑定类/cs文件
public class ItemPageModel: BindableObject
{
private ItemsPage itemsPage;
public ItemPageModel(ItemsPage itemsPage)
{
this.itemsPage = itemsPage;
AddItems();
}
private void AddItems()
{
Items.Add(new DashboardItemList { Title = "Junction List", Icon = "baseline_view_list_white_48.png", Id = ManuItemList.JunctionList });
Items.Add(new DashboardItemList { Title = "Live Monitoring", Icon = "baseline_visibility_white_48.png" , Id = ManuItemList.LiveMonitoring });
Items.Add(new DashboardItemList { Title = "Specification", Icon = "baseline_details_white_36.png" , Id = ManuItemList.Specification });
Items.Add(new DashboardItemList { Title = "Time Setting", Icon = "baseline_settings_applications_white_48.png", Id = ManuItemList.TimeSetting });
Items.Add(new DashboardItemList { Title = "Fault Logs", Icon = "baseline_add_alert_white_48.png" , Id = ManuItemList.FaultLogs });
Items.Add(new DashboardItemList { Title = "Linking Status", Icon = "baseline_link_white_48.png" , Id = ManuItemList.LinkingStatus });
Items.Add(new DashboardItemList { Title = "Linking Status", Icon = "https://farm9.staticflickr.com/8625/15806486058_7005d77438.jpg" });
}
private ObservableCollection<DashboardItemList> _items = new ObservableCollection<DashboardItemList>();
public ObservableCollection<DashboardItemList> Items
{
get
{
return _items;
}
set
{
if (_items != value)
{
_items = value;
OnPropertyChanged(nameof(Items));
}
}
}
public Command ItemTappedCommand
{
get
{
return new Command(async (sender) =>
{
var Item = sender as DashboardItemList;
await Navigation.PushAsync(new JunctionList());
});
}
}
}
}
我尝试了很多方法去另一个,但我得到了异常或应用程序崩溃
这是我点击标签后进入的另一个页面
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="MITSAPP.Views.JunctionList">
<ContentPage.Content>
<StackLayout>
<Label Text="Welcome to Xamarin.Forms!"
VerticalOptions="CenterAndExpand"
HorizontalOptions="CenterAndExpand" />
</StackLayout>
</ContentPage.Content>
【问题讨论】:
标签: xaml xamarin.forms xamarin.android navigation