【问题标题】:How to remove unnecessary data from listView?如何从 listView 中删除不必要的数据?
【发布时间】:2016-08-03 08:14:15
【问题描述】:

所以,我是 Xamarin 的新手,为了获得一些经验,我想编写一个应用程序来提醒我已保存的即将到来的约会。为此,我创建了一个即将到来的约会列表。但是,我不知道如何从列表中自动删除过去的约会。 相关的 xaml 文件如下所示:

<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>

由定义的列表

    {
    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" });
        }

    }
}

从上一部分开始,Appointment 类中的相关数据也应该清楚了。

我在MV或M端如何处理约会通过的情况?

【问题讨论】:

标签: c# xaml listview xamarin xamarin.forms


【解决方案1】:

正如 Rohit 建议的那样,您可以从 observable 集合中删除项目。什么时候做的问题是另一个问题。我建议您查看 Xamarin Forms 中的 App lifecycle of the app

在你的App的简历上,你可以做正确的操作。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-08-10
    • 2017-12-11
    • 1970-01-01
    • 1970-01-01
    • 2014-01-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多