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 8300419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T16:33:26+00:00 2026-06-08T16:33:26+00:00

I am having trouble with Binding in WP7 and cannot find an example or

  • 0

I am having trouble with Binding in WP7 and cannot find an example or blog that will help. My application has a ViewModel and when navigating from a main page (list) to an edit/detail page I have issues with displaying a ListPicker and Object data correctly binded on the same page. I have managed to make this work, but wish to find the best practise for this.

For example I have a class:

public class Person
    {
        public string Name { get; set; }
        public string Gender { get; set; }
    }

The class is also referenced in my viewmodel:

public Person selectedPerson;
private Person _person
{
    get { return _person; }
    set
    {
        _person= value;
        NotifyPropertyChanged("selectedPerson");
    }
}

I have a Detail.xaml page:

<StackPanel x:Name="PersonEditPanel">
    <TextBox x:Name="NameTextBox" Text="{Binding Name}" />
    <TextBox x:Name="GenderTextBox" Text="{Binding Gender}" />
</Stackpanel>

And In my code behind, I have:

private void PhoneApplicationPage_Loaded(object sender, EventArgs e)
{
    DataContext = App.ViewModel.selectedPerson;
}

The above is fine, but I would like to add a ListPicker for the Gender attribute to improve user experience.

To achieve this, I add a new class:

public class TypeList
    {
        public int ID { get; set; }
        public string Name { get; set; }
    }

And add an observable collection to my ViewModel:

private ObservableCollection<TypeList> _PersonGenderTypeList;
    public ObservableCollection<TypeList> PersonGenderTypeList
    {
        get { return _PersonGenderTypeList; }
        set
        {
            _PersonGenderTypeList = value;
            NotifyPropertyChanged("PersonGenderTypeList");
        }
    }

I have tried many options and the only way I can find where I am able to see the correctly binded Person Name and the Gender list pick and populated on screen (at the same time) is as below:

private void PhoneApplicationPage_Loaded(object sender, EventArgs e)
{
    DataContext = App.ViewModel.selectedPerson;
    GenderTypeListPicker.ItemsSource = App.ViewModel.PersonGenderTypeList;
}

This feels like a real hack and probably not best practise. Am I missing something here and if so is there a better way to achieve this?

  • 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-08T16:33:27+00:00Added an answer on June 8, 2026 at 4:33 pm

    I would not class your code as a hack, it is simple and does the job. You could make use of the MVVM pattern and create a view model which ‘backs’ the page, containing both the selected person and the genders:

    public PersonDetailsViewModel
    {
      public Person SelectedPerson {get;set;}
      public ObservableCollection<TypeList> GenderList {get;set;}
    }
    

    You can then set the instance of this view model as the DataContext of your view, then bind the various UI controls in XAML.

    However, as I said before, there is nothing strictly wrong with your current code!

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

Sidebar

Related Questions

I am having trouble binding a Command that is generated up the UI tree
Having trouble with each function... Will try to explain by example... In my code,
I'm working with a Panorama WP7 project, and I'm having trouble binding my viewmodels
Using jQuery 1.7 I'm having trouble binding a Click event to some dynamically loaded
I'm using Hibernate 4.0.1.Final. I'm having trouble binding a session when testing my service.
I'm having some trouble getting binding to work with JQuery. <iframe id=wufooFormz7x3k1 height=281 allowtransparency=true
I'm having trouble binding values to dynamically created controls. When a user loads a
I am having a little trouble understanding ServiceKnownType in WCF. Taken from this blog
I'm having trouble filtering hierarchical data that's being displayed in nested xaml templates. I've
I'm having trouble binding the selected value of a drop down list to the

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.