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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:45:44+00:00 2026-06-09T06:45:44+00:00

When my usercontrol(WindowScreen) loads for the first time, my elementhost displays correctly. When I

  • 0

When my usercontrol(WindowScreen) loads for the first time, my elementhost displays correctly. When I instantiate the usercontrol and pass in a different id, the elementhost doesnt get updated. Is there a reason why for this or is there a way to fix this?

Here’s my code.

WindowScreen.cs — winform:

public partial class WindowScreen : UserControl
{
    private WindowView _windowView;
    private WindowViewModel _windowViewModel = null;

    public WindowScreen(int id)
    {
        InitializeComponent();

        elementHost.Child = this.elementHost1;
        _windowViewModel = new WindowViewModel();
        _windowView = (WindowView) this.elementHost.Child;
        //_windowViewModel.LoadTypes(123); --- first load
                  _windowViewModel.LoadTypes(id); --- pass in parameter
        _windowView.DataContext = _windowViewModel;
    }
}

TestScreen.cs — winform:

public partial class TestScreen : UserControl
{
    public TestScreen()
    {
        InitializeComponent();  
    }

    private void button1_Click(object sender, EventArgs e)
    {
        WindowScreen ws = new WindowScreen(298);
    }
}
  • 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-09T06:45:55+00:00Added an answer on June 9, 2026 at 6:45 am

    When you call this:

    WindowScreen ws = new WindowScreen(298);
    

    You’re creating a new WindowScreen, but never setting it to be used in your TestScreen control. You need to overwrite the current WindowScreen with this one – something like:

    // This needs to be the appropriate/correct variable
    this.windowScreen1 = new WindowScreen(298);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

To add a usercontrol in codebehind there are two ways. Exposing a usercontrol constructor
I have a UserControl with the following Property: public List<Rect> HotSpots { get {
I have an custom UserControl that displays an image, i'm trying to use this
I have a UserControl named myControl and there is a 3 columns Grid within
I have a UserControl that allows the user to upload files and also displays
My UserControl contains a TextBox and a Button. The TextBox's Text is correctly populated
net usercontrol located on on my aspx page. In the usercontrol there is a
UserControl: How to set Output Cache duration programmatically?
The UserControl class inherits from TemplateControl which implements INamingContainer. Since this is only a
In a WPF 4 UserControl I could define the bindings of a sub control

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.