Xaml 应用程序没有';t使用两个工具栏项构建
我试图在XAML中创建一个包含两个工具栏项的页面,这两个工具栏项在两个平台之间存在差异,但我的应用程序无法生成。我有“对象引用未设置为对象实例”错误 这是我的页面文件Xaml 应用程序没有';t使用两个工具栏项构建,xaml,xamarin,xamarin.forms,prism,Xaml,Xamarin,Xamarin.forms,Prism,我试图在XAML中创建一个包含两个工具栏项的页面,这两个工具栏项在两个平台之间存在差异,但我的应用程序无法生成。我有“对象引用未设置为对象实例”错误 这是我的页面文件 <?xml version="1.0" encoding="utf-8" ?> <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
prism:ViewModelLocator.AutowireViewModel="True"
x:Class="VFood.Views.EntregadorEdit"
Title="{Binding Title}">
<ContentPage.ToolbarItems>
<OnPlatform x:TypeArguments="ToolbarItem">
<OnPlatform.iOS>
<ToolbarItem x:Name="SalvarItemIOS" Name="Done" Command="{Binding SalvarCommand}" Order="Primary" Priority="0"/>
<ToolbarItem x:Name="RemoveItemIOS" Name="Trash" Command="{Binding RemoveCommand}" Order="Primary" Priority="1"/>
</OnPlatform.iOS>
<OnPlatform.Android>
<ToolbarItem x:Name="SalvarItemDroid" Icon="ic_check" Command="{Binding SalvarCommand}" Order="Primary" Priority="0"/>
<ToolbarItem x:Name="RemoveItemDroid" Icon="ic_delete" Command="{Binding RemoveCommand}" Order="Primary" Priority="1"/>
</OnPlatform.Android>
</OnPlatform>
</ContentPage.ToolbarItems>
<ContentPage.Content>
<StackLayout Spacing="8">
<StackLayout.Padding>
<OnPlatform x:TypeArguments="Thickness" Android="16,16,16,16" iOS="10,10,10,10"/>
</StackLayout.Padding>
<Entry Placeholder="Nome" Text="{Binding Entregador.Nome}"/>
<Entry Placeholder="Telefone" Text="{Binding Entregador.Telefone}" Keyboard="Telephone" />
</StackLayout>
</ContentPage.Content>
</ContentPage>
如果我为每个平台注释一个toolbaritem,就像下面的代码一样,构建就像一个符咒,但是如果我尝试使用这两个toolbaritem构建,我会出错
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
prism:ViewModelLocator.AutowireViewModel="True"
x:Class="VFood.Views.EntregadorEdit"
Title="{Binding Title}">
<ContentPage.ToolbarItems>
<OnPlatform x:TypeArguments="ToolbarItem">
<OnPlatform.iOS>
<!--<ToolbarItem x:Name="SalvarItemIOS" Name="Done" Command="{Binding SalvarCommand}" Order="Primary" Priority="0"/>-->
<ToolbarItem x:Name="RemoveItemIOS" Name="Trash" Command="{Binding RemoveCommand}" Order="Primary" Priority="1"/>
</OnPlatform.iOS>
<OnPlatform.Android>
<!--<ToolbarItem x:Name="SalvarItemDroid" Icon="ic_check" Command="{Binding SalvarCommand}" Order="Primary" Priority="0"/>-->
<ToolbarItem x:Name="RemoveItemDroid" Icon="ic_delete" Command="{Binding RemoveCommand}" Order="Primary" Priority="1"/>
</OnPlatform.Android>
</OnPlatform>
</ContentPage.ToolbarItems>
<ContentPage.Content>
<StackLayout Spacing="8">
<StackLayout.Padding>
<OnPlatform x:TypeArguments="Thickness" Android="16,16,16,16" iOS="10,10,10,10"/>
</StackLayout.Padding>
<Entry Placeholder="Nome" Text="{Binding Entregador.Nome}"/>
<Entry Placeholder="Telefone" Text="{Binding Entregador.Telefone}" Keyboard="Telephone" />
</StackLayout>
</ContentPage.Content>
</ContentPage>
类似的东西应该会起作用(没有人说XAML不够详细,谢谢你!工作起来很有魅力,是的,这是一种多么冗长的语言hahaha@ViníciusdaCruzMaia很高兴这有帮助;-)