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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:00:01+00:00 2026-05-16T18:00:01+00:00

I set up two Windows in my WPF C# Blend project. Now what I

  • 0

I set up two Windows in my WPF C# Blend project. Now what I would like to know (and I have trouble finding some clear documentation) is how to run both windows on application startup and in what way I can pass code from window to window.

Thanks

  • 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-16T18:00:01+00:00Added an answer on May 16, 2026 at 6:00 pm

    In the app.xaml file for the solution, it specifies which window to run upon startup. A quick solution to open the other one is to tack on an event handler to the startup window’s Loaded event which opens the second window.

    However, that’s not too scalable of a solution if this is part of a larger project. Having a separate class which can open each window, then neither window needs to know about the other.

    As for passing data between them, using events can offer a more loosely-coupled solution. I’d push for a more MVVM (Model-View-ViewModel) architecture, then let each of the ViewModels raise events that the other can respond to. You can declare your own subclass of EventArgs which would supply the information which needs to be passed.

    Update

    Sorry for the delay in response. Simply, to have one Window share data with another Window, the receiver must have a way to receive that data. Defining a public property in the receiver will allow the sender to specify the data with a simple property call. By default, a Window’s controls are internal, so you can access them within the same assembly, but that’s not the best way to do it.

    WPF has a really rich binding infrastructure that you should be taking advantage of. Do do this, your object which is providing data to the Window needs to implement the INotifyPropertyChanged interface. This will alert the UI that data has changed, and the binding should update the target with the changed data. The MSDN page describing the interface as well as a sample implementation can be found here.

    When you implement that interface, that will expose an event (PropertyChanged) which will fire when data has been changed. The object providing data to the other window can register an event handler to listen for these changes, and then it will have the updated value.

    Here’s an example implementation of a simple class with a FirstName and LastName property.

    class FirstNameViewModel : INotifyPropertyChanged
    {
      public event PropertyChangedEventHandler PropertyChanged;
    
      private string firstName;
      public string FirstName
      {
        get { return firstName; }
        set
        {
          if(firstName == value)
            return;
    
          firstName = value;
          if(PropertyChanged != null)
            PropertyChanged(this, new PropertyChangedEventArgs("FirstName"));
        }
      }
    
      private string lastName;
      public string LastName
      {
        get { return lastName; }
        set
        {
          if(lastName == value)
            return;
    
          lastName = value;
          if(PropertyChanged != null)
            PropertyChanged(this, new PropertyChangedEventArgs("LastName"));
        }
      }
    }
    

    You can see that there’s some code duplication in here–that’s often refactored into a base ViewModel class. You’ll see that this exposes the PropertyChanged event. Attach an event handler to it, and in the PropertyChangedEventArgs object the handler receives, the PropertyName property will contain the name of the property that was changed (the same as the string passed to the constructor in each of the setters above). The sender parameter will be a reference to the object itself. Cast it to the correct type, and you’ll have access to the properties.

    Hopefully that gets you a start. I wrote a very contrived sample that I can upload somewhere if you’d like to see it. It opens 2 windows, then you can see that typing in one window causes the typed text to appear in the other one, and vice versa.

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

Sidebar

Related Questions

I have two windows form and both set the topmost property to true. But
I have two Spring proxies set up: <bean id=simpleBean class=org.springframework.aop.framework.ProxyFactoryBean> <property name=target> <ref local=simpleBeanTarget/>
I have two report parameters that were set up automatically when I created their
I have set up transactional replication between two SQL Servers on different ends of
I have two named instances of SQL Server 2008 and am trying to set
In WPF, there are two ways to set the focus to an element. You
Hi I have a master and cloned TClientData set CdsCloned.CloneCursor(CdsMaster,true); CdsMaster has two Fields
I wrote an application that loops through a set of records and prints two
I was recently having some issues with a bigger project, but in an effort
I have built a Wpf UserControl Library and it contains a large group of

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.