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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:54:58+00:00 2026-06-13T02:54:58+00:00

Title pretty much says it all. The score is being displayed as 0 (which

  • 0

Title pretty much says it all. The score is being displayed as 0 (which is what I initialized it to). However, when updating the Score it’s not propagating to the UI textBlock. Thought this would be pretty simple, but I’m always running into problems making the switch from Android 🙂 Am I suppose to be running something on the UI thread??

I’m trying to bind to the “Score” property.

<TextBox x:Name="text_Score" Text="{Binding Score, Mode=OneWay}" HorizontalAlignment="Left" Margin="91,333,0,0" Grid.Row="1" TextWrapping="Wrap" VerticalAlignment="Top" Height="148" Width="155" FontSize="72"/>

Here is my holder class

   public class GameInfo
    {
        public int Score { get; set; }
        public int counter = 0;
    }

**Note: Make sure you don’t forget to add {get; set;} or else nothing will show up.

and this is where I’m trying to set it

protected override void OnNavigatedTo(NavigationEventArgs e)
{
    base.OnNavigatedTo(e);
    info.counter = (int)e.Parameter;

    text_Score.DataContext = info;
}

P.S. To reiterate, I’m going for OneWay. I only want to display the score and have it undated when the variable changes. I plan on disabling user input.

Here is the full working code example. The only thing that had to change was my holder class. Thanks Walt.

public class GameInfo : INotifyPropertyChanged
{
    private int score;
    public int Score {
        get { return score; }
        set
        {
            if (Score == value) return;
            score = value;
            NotifyPropertyChanged("Score");
        }
    }
    public int counter = 0;

    public event PropertyChangedEventHandler PropertyChanged;

    private void NotifyPropertyChanged([CallerMemberName] String propertyName = "")
    {
        if (PropertyChanged != null)
        {
            PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}
  • 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-13T02:54:59+00:00Added an answer on June 13, 2026 at 2:54 am

    In XAML binding your underlying class needs to inform the binding framework that the value has changed. I your example, you are setting the counter in the OnNavigatedTo event handler. But if you look at your GameInfo class, it’s a simple data object.

    The INotifyPropertyChanged interface is used to notify clients, typically binding clients, that a property value has changed. So in your case, change the class as follows

    public class GameInfo : INotifyPropertyChanged
    {
        private int _score;
    public int Score
    {
      get
      {
        return this._score;
      }
    
      set
      {
        if (value != this._score)
      {
        this._score = value;
        NotifyPropertyChanged("Score");
      }
    }
    
      }    
    public int counter = 0; // if you use _score, then you don't need this variable.
        public event PropertyChangedEventHandler PropertyChanged;
    
         private void NotifyPropertyChanged([CallerMemberName] String propertyName = "")
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    
    }
    

    See the MSDN article for more information INotifyPropertyChanged

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

Sidebar

Related Questions

The title pretty much says it all. I have a listview being populated by
title pretty much says it all. I have a website which will only run
Title pretty much says it all. The web.config, unchanged from how VS2008SP1 generated it,
The title pretty much says it all, but basically I have a main parent
The title pretty much says it all, but in SQL Server 2005 Management Studio,
The title pretty much says it all. When I'm doing some reflection through my
The title pretty much says it all, how do I know if I'm getting
The title pretty much says it all, but here's some background. We have a
The title pretty much says it all, so here's the code: #include <stdio.h> /*
The title pretty much says it all, I've got a 'web site' that was

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.