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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T13:29:09+00:00 2026-06-02T13:29:09+00:00

In my usercontrol ViewUser the groupbox header and textblock isnt displaying UserID? Main Window:

  • 0

In my usercontrol ViewUser the groupbox header and textblock isnt displaying UserID?

Main Window:

private void btnGeneral_Click(object sender, RoutedEventArgs e)
{

    ViewUser myusercontrol = new ViewUser();
    String id = (String)((Button)sender).Tag;
    myusercontrol.UserID = id;
    PanelMainContent.Children.Add(myusercontrol);

}
 private void button1_Click(object sender, RoutedEventArgs e)
 {
         string uriUsers = "http://localhost:8000/Service/User";
            XDocument xDoc = XDocument.Load(uriUsers);
            var sortedXdoc = xDoc.Descendants("User")
                           .OrderByDescending(x => Convert.ToDateTime(x.Element("TimeAdded").Value));
            foreach (var node in xDoc.Descendants("User"))
            {

                Button btnFindStudent = new Button();
                btnUser.Click += this.btnGeneral_Click;
                btnUser.Tag = String.Format(node.Element("UserID").Value);
                //also tryed btnUser.Tag = node.Element("UserID").Value;

UserControl:

public partial class ViewUser : UserControl
{
    public ViewUser()
    {
        InitializeComponent();
    }
    private string _user;

    public string UserID
    {
        get { return _userID; }
        set { _userID = value; }
    }
    protected override void OnInitialized(EventArgs e)
    {
        base.OnInitialized(e);
        groupBox1.Header = UserID;
        textBlock1.Text = UserID;
    }
}

}

  • 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-02T13:29:11+00:00Added an answer on June 2, 2026 at 1:29 pm

    Kirsty, you should update the GroupBox and TextBlock every time the UserID property changes:

    public string UserID 
    { 
        get { return _userID; } 
        set
        {
            _userID = value;
            groupBox1.Header = _userID; 
            textBlock1.Text = _userID; 
        } 
    } 
    

    Currently you’re updating the GroupBox and TextBlock only a single time in OnInitialized. But OnInitialized is called only once after the ViewUser control is initialized and never again.

    This is what n8wrl meant with the second part of his answer.

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

Sidebar

Related Questions

I have a UserControl which contains a TextBox . When my main window loads
Suppose I have a UserControl whose DataContext is set to an object that has
I have .net usercontrol and I show it in asp.net page as Object. If
I have a usercontrol: <Grid x:Name=LayoutRoot Background=White> <TextBlock Name=TextBlock1 Text=Text for></TextBlock> </Grid> It has
I have a usercontrol (UC) that is sometimes in a window and sometimes in
UserControl: How to set Output Cache duration programmatically?
The UserControl class inherits from TemplateControl which implements INamingContainer. Since this is only a
I've created a usercontrol in the C# (ASP.NET) designer. It works fine (when I
I have a simple UserControl for database paging, that uses a controller to perform
Is there a custom UserControl created in WPF that allows for RDP access. 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.