Forum Cross Platform with Xamarin

Xaml Page Error When Binding Date From ViewModel Class

MarkVincentMarkVincent PHMember ✭✭✭

I am having this error when I am trying in opening my form.

I am calling my mainviewmodel where it handles my insert data async.

   <?xml version="1.0" encoding="utf-8" ?>
   <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
               xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
               x:Class="LoadDetailsMobileApplication.Views.LoadDetailsForm"
               xmlns:ViewModels="clr-namespace:LoadDetailsMobileApplication.ViewModels;assembly=LoadDetailsMobileApplication">
   <ContentPage.BindingContext>
      <ViewModels:MainViewModel />
   </ContentPage.BindingContext>
    // ... Binding entries

Here's my mainviewmodel

private List<LoadDetails> _loadDetailsList;
private LoadDetails _selectLoadDetails = new LoadDetails();
public LoadDetails selectLoadDetails
{
    get { return _selectLoadDetails; }
    set { _selectLoadDetails = value; OnPropertyChanged();}
}
public Command InsertLoadDetailsCommand
{
    get
    {
        return new Command(async () =>
        {
            await loadDetailsServices.InsertLoadDetails(_selectLoadDetails);
        });
    }
}
// ... below contains my property change

My problem is, whenever I remove the

= new LoadDetails();

in

private LoadDetails _selectLoadDetails = new LoadDetails();

it's working. But there is null value in my _selectLoadDetails.

Please help.

Best Answer

Answers

  • MarkVincentMarkVincent PHMember ✭✭✭
    edited July 2016

    How can I see that "root exception" ?

  • MarkVincentMarkVincent PHMember ✭✭✭

    You gave me an idea about the property. I have DateTimePicker in my Xaml Form and my model for DateTime is string. I changed it to DateTime and now it's working. Thank you @Dylan :) God bless! +

  • SturgmeisterSturgmeister USUniversity ✭✭

    @MarkVincent Great! I'm glad you resolved the issue.

Sign In or Register to comment.