Xaml Xamarin Forms FAB崩溃
嗨,我正在尝试在我的Xamarin.Forms应用程序上创建一个简单的FAB。我正在使用Nuget软件包来实现这一点(最新的预发布版) 因此,这是xaml代码应该可以工作,但由于某些原因不能工作的地方:Xaml Xamarin Forms FAB崩溃,xaml,xamarin,xamarin.android,xamarin.forms,floating-action-button,Xaml,Xamarin,Xamarin.android,Xamarin.forms,Floating Action Button,嗨,我正在尝试在我的Xamarin.Forms应用程序上创建一个简单的FAB。我正在使用Nuget软件包来实现这一点(最新的预发布版) 因此,这是xaml代码应该可以工作,但由于某些原因不能工作的地方: <?xml version="1.0" encoding="utf-8" ?> <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.mi
<?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);
}
}
}
使用系统;
使用System.Collections.Generic;
使用System.Linq;
使用系统文本;
使用System.Threading.Tasks;
使用Xamarin.Forms;
使用Xamarin.Forms.Xaml;
使用LoginSystem.Models;
使用LoginSystem.ViewModels;
使用晶圆形式;
名称空间LoginSystem.Views
{
[XamlCompilation(XamlCompilationOptions.Compile)]
公共部分类DailyPage:ContentPage
{
公共每日网页()
{
初始化组件();
var items=新列表();
对于(int i=0;i<30;i++)
{
Add(string.Format(“Abbas{0}”,i));
}
this.List.ItemsSource=项目;
NavigationPage.SetHasBackButton(此选项为false);
//BindingContext=newdailypage_vm();
}
公共每日页面(字符串电子邮件、字符串密码)
{
初始化组件();
NavigationPage.SetHasBackButton(此选项为false);
this.BindingContext=新的DailyPage_vm(电子邮件、密码);
}
}
}
我已经尝试在已经发布的旧版本Nuget上执行此操作,但没有成功。是否引发异常?如果包含来自崩溃的信息,则解决此问题会容易得多。我在构造函数中使用了try-catch,但它没有捕获任何内部信息。我不认为异常是在itI之外产生的,我使用你的代码,它工作正常,也许问题发生在其他地方?问题是,当我注释掉FAB部分时,我的程序没有崩溃;所以我想它应该在里面?但是如果你说我的代码在你的项目上完美地工作,那么我不得不认为你是对的。