none
How to capture a date in Xamarin and process it in ShellView.xaml.cs file

    Question

  • Greetings

    I am building a WPF UI that captures date of birth and adds it to PersonType object so it can be inserted into an instance of MongoDB. I am using Caliburn.Micro also and I get compiler errors when I try to extend the Screen class and when I want to use NotifyOfPropertyChange(); it says Notify... does not exist in the current context. I get another compiler error under ShellView which says: "Partial declarations of ShellView must not specify different base classes."

    
    public partial class ShellView : Screen
        {
            MongoCRUD da = new MongoCRUD("mongoChallenge");

            PersonModel newPerson = new PersonModel();
            private List<PersonModel> _people;

            public List<PersonModel> People
            {
                get { return _people; }
                set
                {
                    _people = value;
                    NotifyOfPropertyChange<List<PersonModel>>(()=>People);
                }
            }

            public ShellView()
            {
                
                InitializeComponent();
                
                
            }
            
            private void SubmitButton_Click(object sender, RoutedEventArgs e)
            {
                
                
            }

            private void NewPerson_Click(object sender, RoutedEventArgs e)
            {
                
                newPerson.FirstName = firstName.Text;
                newPerson.LastName = lastName.Text;
                List<PersonModel> People = new List<PersonModel>();
                AddressModel newAddress = new AddressModel();
                newAddress.StreetAddress = StreetAddress.Text;
                newAddress.City = City.Text;
                newAddress.State = State.Text;
                newAddress.ZipCode = ZipCode.Text;
                newPerson.PrimaryAddress = newAddress;
                People.Add(newPerson);
                da.InsertRecord<PersonModel>("challengeUsers", newPerson);
                People = da.LoadRecords<PersonModel>("mongoChallenge");
                
            }

            private void DateOfBirth_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
            {
                newPerson.DateOfBirth = dateOfBirth.DisplayDate;
            }
        }
    ...
    <Label Grid.Row="5" Grid.Column="0">
                Enter the first name:
            </Label>
            <TextBox Grid.Row="5" Grid.Column="1" MinWidth="100"
               Name="firstName" Margin="0,0,0,0"/>

            <Label Grid.Row="6" Grid.Column="0" >
                Enter the last name:
            </Label>
            <TextBox Grid.Row="6" Grid.Column="1" MinWidth="100"
               Name="lastName" Margin="0,0,0,0"/>
            <Label Grid.Row="7" Grid.Column="0">Date of Birth</Label>
            <DatePicker Grid.Row="7" Grid.Column="7" Name="dateOfBirth"/>
            <Label Grid.Row="8" Grid.Column="0">Street Address</Label>
            <TextBox Grid.Row="8" Grid.Column="1" Name="StreetAddress" Margin="0,0,0,0" MinWidth="100"/>
            <Label Grid.Row="9" Grid.Column="0">City</Label>
            <TextBox Grid.Row="9" Grid.Column="1" Name="City" Margin="0,0,0,0" MinWidth="100"/>
            <Label Grid.Row="10" Grid.Column="0">State</Label>
            <TextBox Grid.Row="10" Grid.Column="1" Name="State" Margin="0,0,0,0" MinWidth="100"/>
            <Label Grid.Row="11" Grid.Column="0">ZipCode</Label>
            <TextBox Grid.Row="11" Grid.Column="1" Name="ZipCode" Margin="0,0,0,0 " MinWidth="100"/>
            <Button Grid.Row="12" Grid.Column="0" x:Name="NewPerson"
              Margin="2" Click="NewPerson_Click">
                Submit New Person
            </Button>

            <Button Grid.Row="13" Grid.Column="0" 
              Name="Clear" Margin="2">
                Clear Name
            </Button>
    ...



    Saturday, May 18, 2019 8:12 AM

All replies

  • Hi,

    Since the problem is more related to Xamarin, it is out of the scope of UWP apps, I suggest that you might need to ask about this in the Xamarin's official forum.

    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, May 20, 2019 2:10 AM