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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:44:39+00:00 2026-06-15T08:44:39+00:00

I have 4 classes Comment Class: public class comment { public string Username {

  • 0

I have 4 classes

Comment Class:

public class comment
    {
        public string Username { get; set; }
        public string Comment { get; set; }

        public comment(string _username, string _comment)
        {
            this.Username = _username;
            this.Comment = _comment;
        } 
    }

Pin Class:

   public class Pin : PhoneApplicationPage

        public List<comment> Comment_List;        

    public Pin(){

        this.Comment_List = new List<comment>();
    }
}

Message Page:

public partial class MessagePage : PhoneApplicationPage
{
   Pin _Pin;

   public MessagePage(Pin _pin)
 {        
    this._Pin = _pin;
 }

 public void Refresh()
 {
   this.textbox1.Text = "";
   foreach (comment c in this._Pin.List)
   {
    this.textbox1.Text += c.Username;
   }

  }

public void function()
{
     //Call static function in another class to download new pin info
}

The static function then updates a static class called PinList().

I have an event triggered in PinList() class when Its static List of Pins is updated, How to i address the object that is the current MessagePage to to call a function to update the textbox with the new values in Pin.comments.

i.e. i Have:

public class PinList
    {
        public ObservableCollection<Pin> list;
        public static ObservableCollection<Pin> MainPinList = new ObservableCollection<Pin>();
        public event PropertyChangingEventHandler PropertyChanged;

public PinList()
        {
            list = new ObservableCollection<Pin>();
            list.CollectionChanged += listChanged;            

            ((INotifyPropertyChanged)list).PropertyChanged += new PropertyChangedEventHandler(list_Property_Changed);

        }


    private void list_Property_Changed(object sender, PropertyChangedEventArgs args)
            {
                  //Need to call
                  //MessagePage.Refresh();
            }
  • 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-15T08:44:41+00:00Added an answer on June 15, 2026 at 8:44 am

    From the code you’ve got and the way you’ve worded it it sounds like you’re trying to access MessagePage statically as if it was a singleton but there’s not a single static Property anything there. If you’re dead-set on doing it that way you’ll need to declare a static instance of MessagePage.

    I would recommend, however, that you simply bind an ItemsControl of some sort to react to the Pin.Comment_List and make Comment_List an ObservableCollection<comment> instead of a List<comment> and make sure the comment class implements INotifyPropertyChanged – then the UI will take care of its own updates. It looks like what you’re doing is trying to reinvent the wheel.

    Edit: Based on your comments

    public class Comment : INotifyPropertyChanged
    {
        private string username;
        private string comment;
    
        public comment(string _username, string _comment)
        {
            this.Username = _username;
            this.Comment = _comment;
        }                 
    
        public string Username
        {
            get
            {
                return username;
            }
    
            set
            {
                if(value != username)
                {
                    username = value;
                    NotifyPropertyChanged("Username");
                }
            }
        }                   
    
        public string Comment
        {
            get
            {
                return comment;
            }
    
            set
            {
                if(value != comment)
                {
                    comment= value;
                    NotifyPropertyChanged("Comment");
                }
            }
        }       
    
        public event PropertyChangedEventHandler PropertyChanged;
    
        private void NotifyPropertyChanged(String info)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(info));
            }
        }
    }
    

    Pin Class:

    public class Pin
    {
        private readonly ObservableCollection<Comment> commentList = new ObservableCollection<Comment>();        
    
        public ObservableCollection<Comment> CommentList
        {
            get
            {
                return commentList;
            }
        }
    }
    

    Message Page:

    public partial class MessagePage : PhoneApplicationPage
    {
        private readonly Pin pin;
    
        public MessagePage(Pin _pin)
        {        
            this.pin = _pin;
        }
    
        public Pin Pin
        {
            get
            {
                return pin;
            }
        }
    

    And your data source

    public class PinList
    {
        public ObservableCollection<Pin> list;
        public static ObservableCollection<Pin> MainPinList = new ObservableCollection<Pin>();
    
        public void Refresh()
        {
             // Here you update the comments list of each of your Pins - The comment
             //     list is an ObservableCollection so your display will automatically
             //     update itself. If you have to change an existing comment due to
             //     an edit or something that will automatically update as well since
             //     we've implemented INotifyPropertyChanged
        }
    }
    

    Displaying a Pin’s comments would look something like this as long as you implemented INotifyPropertyChanged on comment and changed Comment_List to an ObservableCollection<comment>. All you would need to do in order to update the messages is add any new messages to that pin’s Comments_List and the UI will react without you having to do anything in singleton or subscribe to a bunch of events.

    <ItemsControl DataContext={Binding Pin} ItemsSource="{Binding CommentList}"">
      <ItemsControl.ItemTemplate>
        <DataTemplate>
          <StackPanel Margin="0 0 0 10">
            <TextBlock Text="{Binding Username, StringFormat='{0} said:'}" FontWeight="Bold" />
            <TextBlock Text="{Binding Comment}" />
          </StackPanel>
        </DataTemplate>
      </ItemsControl.ItemTemplate>
    </ItemsControl>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have classes public class BlogPost { public int Id {get;set;} public string Body{get;set;}
I have two simple classes public class Blog { public Blog(){ Comments=new List<Comment>(); }
I have classes which have automatic properties only like public customerName {get; set;}. They
I have classes structured like this: Public MustInherit Class A ' several properties End
If I have classes of Type A and B: public class A { public
I have two classes, ThreadItem and Enquiry. public class ThreadItem { [Key] public int
When I compile something like this: public class MyClass { void myMethod(String name, String
I have a Java class that looks like this: public class My_ABC { int
I have got these POCO classes: public class Task { public int TaskId {
Say I have classes class A{ //code for class A } class B{ //code

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.