2017-02-08 9 views
0

私は、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) 
    { 
    } 
} 

やっているのですか?

+0

代わりに 'DelegateCommand'を使用しようとしましたか? –

+0

はい、結果は同じでした – Dimitris

+0

あなたはどのバージョンのプリズムを使用していますか? –

答えて

関連する問題