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

  • SEARCH
  • Home
  • 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 7629123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:45:14+00:00 2026-05-31T05:45:14+00:00

I am building a Windows Phone App, and I am trying to bind the

  • 0

I am building a Windows Phone App, and I am trying to bind the ObservableCollection with nested struct without success.

MyViewModel.cs

public class MyViewModel : PropertyChangedBase
{
    private Player _Player1;
    public Player Player1
    {
        get { return _Player1; }
        set
        {
            if (!value.Equals(_Player1))
            {
                _Player1 = value;
                NotifyOfPropertyChange(() => Player1);
            }
        }
    }
    private Player _Player2;
    public Player Player2
    {
        get { return _Player2; }
        set
        {
            if (!value.Equals(_Player2))
            {
                _Player2 = value;
                NotifyOfPropertyChange(() => Player2);
            }
        }
    }
    public struct Player
    {
        public string Name;
        public bool IsWinner;
    }
}

MyPageViewModel.cs

public class MyPageViewModel : Screen
{
    public ObservableCollection<MyViewModel> Matches { get; private set; }
    public MyPageViewModel()
    {
        this.Matches = new ObservableCollection<MyViewModel>();
        LoadData();
    }
    public void LoadData()
    {            
        // Matches
        this.Matches.Add(new MyViewModel()
        { 
            Player1 = new MyViewModel.Player
            { Name = "Jhonn", IsWinner = false },
            Player2 = new MyViewModel.Player
            { Name = "Marrie", IsWinner = true }
        });
    }
}

MyPage.xaml

<ListBox Margin="0,0,-12,0" ItemsSource="{Binding Matches}">
    <ListBox.ItemTemplate>
        <DataTemplate>
            <StackPanel Margin="0,0,0,17" Width="432">
                <TextBlock Text="{Binding Player1.Name}" TextWrapping="Wrap" Style="{StaticResource PhoneTextExtraLargeStyle}"/>
                <TextBlock Text="{Binding Player2.Name}" TextWrapping="Wrap" Style="{StaticResource PhoneTextExtraLargeStyle}"/>
            </StackPanel>
        </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>

I have no binding error, but no players names are showed. I always have a blank screen.

  • 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-05-31T05:45:15+00:00Added an answer on May 31, 2026 at 5:45 am

    Your problem is here:

    public struct Player
    {
        public string Name;
        public bool IsWinner;
    }
    

    In order to be bound, Name needs to be a property. Make Player a class and expose Name as a property on the class and you’ll be golden:

    public class Player
    {
         public string Name {get; set;}
         public bool IsWinner {get;set;}
    }
    

    You should be able to get away without implementing INotifyPropertyChanged, as long as you only set them one time. If they’re going to change, go ahead and implement INPC.

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

Sidebar

Related Questions

I'm building a Windows Phone 7 app, and I need a reference to my
I am building an app for Windows Phone, and in this app I have
I am currently building a measurement unit convertion app for Windows Phone. After setting
Whilst building a Windows Phone 7 app. using the MVVM pattern we've struggled to
I'm building a Windows Phone 7.5 app that needs to play videos that are
I'm building my first simple Windows Phone app. I'm having some trouble though. I'm
I am building an app for windows phone sdk 7.0 and 7.1, I want
I'm building a webapp on Windows Phone 7 and when i'm trying to load
I am building a Windows Phone app which uses the camera. I have the
Perhaps I don't understand events fully. I'm building a Windows Phone 7 app in

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.