2016-08-03 10 views
0

私はXamarinの新作で、私が保存している予定について私に思い出させるAppを書いてみたいと思っています。そのために、今後予定されている予定のリストを作成しました。しかし、過去にあったリ​​ストから予定を自動的に削除する方法はわかりません。 関連するXAMLファイルは次のようになります。その最後の部分からlistViewから不要なデータを削除するには?

{ 
    public class AppointmentCalendarPage : ContentPage 
    { 
     ListView AppointmentView = new ListView(); 
     ObservableCollection<Appointment> appointments = new ObservableCollection<Appointment>(); 
     public AppointmentCalendarPage() 
     { 
      AppointmentView.ItemsSource = appointments; 
      Appointments.Add(new Appointment { ID = 0, Host = 0, AppointmentDate = new DateTime(2016, 12, 24), AppointmentType = "Christmas" }); 
     } 

    } 
} 

によって定義されたリストで

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" 
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
xmlns:constants="clr-namespace:XamarinFormsSample;assembly=XamarinFormsXamlSample" 
x:Class="My.View.AppointmentCalendarView" 
Title="AppointmentCalendarPage"> 
    <ListView x:Name="AppointmentView"> 
    <ListView.ItemTemplate> 
     <DataTemplate> 
     <TextCell Text="{Binding AppointmentDate}: {Binding AppointmentType}" /> 
     </DataTemplate> 
    </ListView.ItemTemplate> 
    </ListView> 
</ContentPage> 

、予定のクラス内の関連するデータも明確にする必要があります。

予定を過ぎた場合の処理​​をMVまたはM側で行うにはどうすればよいですか?

+0

観測可能なコレクションから削除できます。 –

+0

どうすればいいですか? – JLN

+0

https://msdn.microsoft.com/en-us/library/ms654938(v=vs.110).aspx –

答えて

0

Rohitが示唆しているように、オブザーバブルコレクションからアイテムを削除できます。いつ行うべきかという疑問が別の問題です。 XamarinフォームのApp lifecycle of the appをご覧ください。

あなたのアプリケーションの再開時に、正しい操作を行うことができます。

関連する問題