您好我正在尝试在我的Xamarin.Forms应用程序上创建一个简单的FAB。我正在使用FAB.Forms Nuget Package来实现这一目标(最新的预发行版)。
所以这是应该有效的xaml代码,但不是出于某种原因:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="LoginSystem.Views.DailyPage"
xmlns:ViewModels="clr-namespace:LoginSystem.ViewModels"
xmlns:fab='clr-namespace:FAB.Forms;assembly=FAB.Forms'
BackgroundColor="Azure"
Title="Daily-Stats">
<ContentPage.Content>
<RelativeLayout>
<!--<StackLayout VerticalOptions="Center">
<Label Text="Welcome your Daily-Stats!" TextColor="Blue" FontSize="Large" VerticalOptions="Center" HorizontalOptions="Center" Margin="0,0,0,50" />
<Label Text="Page Under Construction" TextColor="Yellow" FontSize="Medium" VerticalOptions="Center" HorizontalOptions="Center" Margin="0,0,0,80" />
</StackLayout>-->
<ContentView
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1}"
RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1}">
<ListView x:Name="List" BackgroundColor="White">
<ListView.ItemTemplate>
<DataTemplate>
<TextCell TextColor="Gray" Text="{Binding .}"/>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</ContentView>
<fab:FloatingActionButton
Source="drawable/Add"
Size="Normal"
RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1, Constant=-75}"
RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1, Constant=-75}"
/>
</RelativeLayout>
</ContentPage.Content>
</ContentPage>
该应用程序因任何原因而崩溃。
这是上述xaml的.cs文件:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
using LoginSystem.Models;
using LoginSystem.ViewModels;
using FAB.Forms;
namespace LoginSystem.Views
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class DailyPage : ContentPage
{
public DailyPage()
{
InitializeComponent();
var items = new List<string>();
for (int i = 0; i < 30; i++)
{
items.Add(string.Format("Abbas {0}", i));
}
this.List.ItemsSource = items;
NavigationPage.SetHasBackButton(this, false);
//BindingContext = new DailyPage_vm();
}
public DailyPage(string email, string password)
{
InitializeComponent();
NavigationPage.SetHasBackButton(this, false);
this.BindingContext = new DailyPage_vm(email, password);
}
}
}
我已经尝试在Old上发布这项工作已经发布Nuget,但没有运气。