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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:08:39+00:00 2026-06-01T16:08:39+00:00

The aim is to create an object that contains a number of WPF windows,

  • 0

The aim is to create an object that contains a number of WPF windows, which would represent a unit that should always be shown together, each Window retaining its own individual responsibilities – say choosing to be laid out on a screen X …

Now because WPF is a single-window architecture, I would like to wrap this list of Windows in a single Window object, so that it could be set as StartupUri, for instance.

  • I know I could manually Show() each Window in Application startup, but that is not the point – I need a collection of windows that stick together and which I can easily call upon anywhere in my codebase, knowing I have one class that has taken care of the linkage.
  • Not interested in Multiple Document Interface MDI here

I do not know how to implement such an adapter, I tried to override BeginInit, but that did not get called at all.

How to stop Window initialization

public class MultiWindow : Window
{
    private readonly IList<Window> _windows = new List<Window>();

    public void Register(Window window)
    {
        _windows.Add(window);
    }

    public override void BeginInit()
    {
        foreach (var w in _windows)
            w.Show();
        // base.BeginInit();
    }
}

I do not understand Window lifecycle much, is there anyhow I could cancel the initialization and show the list of registered windows instead?

  • 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-01T16:08:40+00:00Added an answer on June 1, 2026 at 4:08 pm

    I found a way to do it, which is by making all my windows subclass BaseWindow, for both normal single Window objects and for Window objects actually containing multiple windows.

    • Now when you call .Show() it will either show one window or multiple, depending on what is encapsulated in the subclass.

    All Window objects should inherit from BaseWindow

    public class BaseWindow : Window
    {
        
        // Hide default implementation and call BaseShow instead
        public new void Show()
        {
            BaseShow();
        }
    
        protected virtual void BaseShow()
        {
            base.Show();
        }
    
        // ... abstract away any additional Window methods and properties required 
    }
    

    Override BaseShow()

    public class MultiWindow : BaseWindow
    {        
        private readonly IList<Window> _windows = new List<Window>();
    
        public void Register(Window window)
        {
            _windows.Add(window);
        }
    
        protected override void BaseShow()
        {
            foreach (var w in _windows)
               w.Show();
        }       
    }
    

    Set up MultiWindow in application startup

     // First Window object instantiated becomes WPF MainWindow     
     var multiWindow = new MultiWindow();
     multiWindow.Register(new WindowA());
     multiWindow.Register(new WindowB());
    

    Use MultiWindow, but call overriden members through BaseWindow

    // Cast down to BaseWindow in order to call the overriden member
    var baseWindow = (BaseWindow)Application.Current.MainWindow;
    // Show WindowA and WindowB
    baseWindow.Show();
    

    P.S. I wish Microsoft employed interfaces throughout .NET, working with IWindow interface rather than the concrete Window class would provide much more power and in this case, also ease-of-implementation.

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

Sidebar

Related Questions

My aim is to create identify a piece of code that increments a number
I am trying to create a pageing and sorting object data source that before
how expensive is 'new'? I mean, should I aim at reusing the same object
Aim: to create an Infopath form that displays a list of companies in a
To put this in concise language... Aim: To create a class which can load
I need to store in my object which values have already been handlerd, I
I am attempting to create a singleton service that is used to process incoming
Is it possible in three.js to create transparent/invisible plane, which can receive shadows? My
I am using C#.net Windows form , and I need to create a search
I want to make a constructor function that creates a documentElement object. As an

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.