In my View Model
public ObservableCollection<AddExpenses> _expenses;
public ObservableCollection<AddExpenses> Expenses
{
get
{
if (_expenses == null)
{
_expenses = new ObserrvableCollection<AddExpenses>();
}
return _expenses;
}
}
public ICommand click { get; set; }
public TransactionViewModel(Register_person logindata)
{
click = new Command(add)
}
private void add()
{
var database = new Database();
var expenses = database.GetFinalExpense(10);
foreach (var expense in expenses)
{
Expenses.Add(expense);
}
}
}
In my database.cs
public AddExpenses[] GetFinalExpense(int numberOfExpenses)
{
return Conn.Table<AddExpenses>()
.OrderByDescending(expenses => expenses.Id)
.Take(numberOfExpenses)
.ToArray();
}
I used this code to add these last ten record to my list view using this code. when I called the GetFinalExpense(10) it takes all last 10 records.but when I execute the add function it only shows the two data one is type is DateTime and other is Double. my other two data are in string format. Data binding and XAML part has no issue as far as I know(not Entirely sure)
here my XAML
<ListView ItemsSource="{Binding Expenses}" VerticalOptions="FillAndExpand" >
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Orientation="Vertical">
<StackLayout Orientation="Horizontal">
<Label Text="{Binding Catagoryview}"/>
<Label Text="{Binding Date}"/>
<Label Text="{Binding Expense}"/>
<Label Text="{Binding username}"/>
</StackLayout>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
I need to show all this in list view. Also, I need another favour my DateTime type give me both Date and Time I only need the Date.but it not the main issue is the listview