Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8599099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:19:02+00:00 2026-06-12T01:19:02+00:00

I’m new to Windows Phone development, and currently have a simple form. I’m using

  • 0

I’m new to Windows Phone development, and currently have a simple form. I’m using the MVVM pattern and MvvmLight to run a command. The “Applicant” entity is always empty, and it looks like the 2 way databinding isn’t working. Here is my code, I hope someone can point me in the right direction.

View

   <Grid x:Name="LayoutRoot" Background="Transparent" DataContext="{Binding Applicant}">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>

    <!--TitlePanel contains the name of the application and page title-->
    <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
        <TextBlock x:Name="ApplicationTitle" Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}"/>
        <TextBlock x:Name="PageTitle" Text="create account" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
    </StackPanel>

    <!--ContentPanel - place additional content here-->
    <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
        <StackPanel>
            <StackPanel>
                <TextBlock FontSize="15" TextWrapping="Wrap" Margin="0,0,0,10" Text="Please register to create your applicant account. No information will be passed to third parties for any reason."></TextBlock>
            </StackPanel>
            <StackPanel Orientation="Horizontal">
                <TextBlock VerticalAlignment="Center" Text="Forename" Width="100"></TextBlock>
                <TextBox Width="350" BorderBrush="Red" DataContext="{Binding Forename, Mode=TwoWay}"></TextBox>
            </StackPanel>
            <StackPanel Orientation="Horizontal">
                <TextBlock VerticalAlignment="Center" Text="Surname" Width="100"></TextBlock>
                <TextBox Width="350" x:Name="Surname" BorderBrush="Red" DataContext="{Binding Surname, Mode=TwoWay}"></TextBox>
            </StackPanel>
            <StackPanel Orientation="Horizontal">
                <TextBlock VerticalAlignment="Center" Text="Email" Width="100"></TextBlock>
                <TextBox Width="350" x:Name="EmailAddress" BorderBrush="Red"  DataContext="{Binding EmailAddress, Mode=TwoWay}"></TextBox>
            </StackPanel>
            <StackPanel Orientation="Horizontal">
                <TextBlock VerticalAlignment="Center" Text="Password" Width="100"></TextBlock>
                <PasswordBox Width="350" x:Name="PassPhrase" BorderBrush="Red" DataContext="{Binding PassPhrase, Mode=TwoWay}"></PasswordBox>
            </StackPanel>
            <StackPanel Orientation="Horizontal">
                <TextBlock VerticalAlignment="Center" Text="City" Width="100"></TextBlock>
                <TextBox Width="350" x:Name="City" DataContext="{Binding City, Mode=TwoWay}"></TextBox>
            </StackPanel>
            <StackPanel Orientation="Horizontal">
                <TextBlock VerticalAlignment="Center" Text="State" Width="100"></TextBlock>
                <TextBox Width="350" x:Name="County" DataContext="{Binding County, Mode=TwoWay}"></TextBox>
            </StackPanel>
            <StackPanel Orientation="Horizontal">
                <TextBlock VerticalAlignment="Center" Text="Country" Width="100"></TextBlock>
                <TextBox Width="350" x:Name="Country" DataContext="{Binding Country, Mode=TwoWay}"></TextBox>
            </StackPanel>
            <StackPanel>
                <Button Name="btnContact"
                        Content="Register"
                        DataContext="{Binding ElementName=this, Path=DataContext}"
                        Command="{Binding SaveApplicantCommand}"
                        Width="300"/>
            </StackPanel>
        </StackPanel>
    </Grid>
</Grid>

View code behind

protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
    {
        base.OnNavigatedTo(e);

        ApplicantViewModel vm = new ApplicantViewModel();
        DataContext = vm;
    }

View Model (the view model inherits from ViewModelBase which implements INotifyPropertyChanged)

public class ApplicantViewModel : ViewModelBase
{
    public ApplicantViewModel()
    {
        SaveApplicantCommand = new RelayCommand(SaveApplicant);
        Applicant = new Applicant();
    }

    public ICommand SaveApplicantCommand {get; set;}

    void SaveApplicant()
    {
        if (string.IsNullOrEmpty(Applicant.Forename))
        {
            MessageBox.Show("Please enter a forename", "Oops...", MessageBoxButton.OK);
            return;
        }

        db.AddObject("Applicants", Applicant);
        db.BeginSaveChanges(OnChangesSaved, db);
    }

    void OnChangesSaved(IAsyncResult result)
    {

    }

    private Applicant _applicant;
    public Applicant Applicant
    {
        get
        {
            return _applicant;
        }
        set
        {
            if (_applicant != value)
            {
                _applicant = value;
                RaisePropertyChanged("Applicant");
            }
        }
    }
}

Whatever is entered into the Forename text box, I always get the error message because Forename is null.

***** UPDATE *********

Here is the Forename property in the model

[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
    public string Forename
    {
        get
        {
            return this._Forename;
        }
        set
        {
            this.OnForenameChanging(value);
            this._Forename = value;
            this.OnForenameChanged();
            this.OnPropertyChanged("Forename");
        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T01:19:04+00:00Added an answer on June 12, 2026 at 1:19 am

    An ApplicantViewModel does not have a Forename property. Only Applicant has. So do the following:

    <TextBox Width="350" BorderBrush="Red" 
             DataContext="{Binding Applicant.Forename, Mode=TwoWay}"/>
    

    do the same with the other text boxes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I have a text area in my form which accepts all possible characters from
I have thousands of HTML files to process using Groovy/Java and I need to
I'm making a simple page using Google Maps API 3. My first. One marker
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.