私は、ListViewのXamarin.Formsでプリズムコマンドを使用しようとしていますが、 "ListView.Behaviors"を導入するとすぐにアプリケーションがクラッシュし、 "残念ながらApp1。ドロイドは止まった。プリズムXamarin.Forms EventToCommandBehaviorアプリケーションをクラッシュします
アプリケーションがちょうどプリズムのコマンドをテストするための非常に小さなデモです。このページは "ListView.Behaviors"がなくても正常に動作します。
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"
xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
prism:ViewModelLocator.AutowireViewModel="True"
x:Class="Intro.Views.Example03"
xmlns:b="clr-namespace:Prism.Behaviors;assembly=Prism.Forms"
Title="{Binding Title}">
<ListView ItemsSource="{Binding ContactList}">
<ListView.Behaviors>
<b:EventToCommandBehavior EventName="ItemTapped" Command="{Binding ItemTappedCommand}" />
</ListView.Behaviors>
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Orientation="Horizontal">
<Label Text="{Binding Id}" HorizontalOptions="Center" VerticalOptions="Center" FontSize="Large" />
<StackLayout Orientation="Vertical">
<Label Text="{Binding FirstName}" HorizontalOptions="FillAndExpand" />
<Label Text="{Binding LastName}" HorizontalOptions="FillAndExpand" />
<Label Text="{Binding Email}" HorizontalOptions="FillAndExpand" />
</StackLayout>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</ContentPage>
と背後にあるコードは、私が間違って何を
public class Example03ViewModel : BindableBase, INavigationAware
{
public ICommand ItemTappedCommand
{
get { return _itemTappedCommand; }
set { SetProperty(ref _itemTappedCommand, value); }
}
private ICommand _itemTappedCommand;
public Example03ViewModel()
{
_itemTappedCommand = new Command(ShowDetails);
}
private void ShowDetails(object obj)
{
}
}
やっているのですか?
代わりに 'DelegateCommand'を使用しようとしましたか? –
はい、結果は同じでした – Dimitris
あなたはどのバージョンのプリズムを使用していますか? –