Hello,
Welcome to our Microsoft Q&A platform!
Firstly, your GitHub page cannot be find.
Based on your screenshot, you can get the data from the Sqlite DB, And you insert the Exenpse object successfully, But when you get these records, you get the empty or null result except the ID property, am I right?
If so, this issue is related to your NewExpensePageModel.cs.
You creata new object by Exenpse = new Exenpse(); in the NewExpensePageModel constructor, this Exenpse object do not have any data. But you save this empty Exenpse object in the SaveAction method with following code.
Exenpse = new Exenpse()
{
Name = Exenpse.Name,
Ammount = Exenpse.Ammount,
Descriion = Exenpse.Descriion,
Date = Exenpse.Date,
Catergory = Exenpse.Catergory
};
You can add following layout in your NewExpensesPage.xaml for testing. do not forget to add bindingContext for your NewExpensePageModel.cs
<StackLayout>
<Entry Text="{Binding Exenpse.Name}"></Entry>
<Entry Text="{Binding Exenpse.Descriion}"></Entry>
<Button Text="save" Command="{Binding SaveCommand}"></Button>
</StackLayout>
Then add Appearing event in the ExpensesPage.xaml
<ContentPage.Behaviors>
<community:EventToCommandBehavior EventName="Appearing"
Command="{Binding PageAppearCommand}" />
</ContentPage.Behaviors>
Add the PageAppearCommand and achieve this AppearAction method to get all of data when page appearing.
public ICommand PageAppearCommand { get; set; }
public ExpensesPageModel()
{
Exenpses = new ObservableCollection<Exenpse>();
NewExpense = new Command(NewExpenseAction);
PageAppearCommand = new Command(AppearAction);
GetExpenses();
}
public virtual async void AppearAction()
{
GetExpenses();
}
Here is a ebook about MVVM in Xamarin.Forms. you can read it.
Best Regards,
Leon Lu
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.