Hi

I have two windows (Window1 and Window2) and want to set Window1 as the owner of Window2. Furthermore I want the controls on Window1 to be inherited by Window2. For instance I have a listbox list1 on Window1 and I want list1 to be in context even in Window2. Any ideas?

Thanks

Recommended Answers

All 3 Replies

> want to set Window1 as the owner of Window2.

Owner Form.

>Furthermore I want the controls on Window1 to be inherited by Window2.

Take a look at - How to: Inherit Windows Forms

Thanks for the prompt response, however this has to do with two windows and not forms. From the link you provided, I have tried some variations to the code but both windows share the same namespace "WpfApplication2" and thus I get errors. What I have as the first window is

public partial class Window1 : Window
{
public Window1()
        {
            InitializeComponent();
        }
}

and for the second window,

public partial class Window2 : Window
{
public Window2()
        {
            InitializeComponent();
        }
}

Most controls are declared in Window1, how can I reference the controls of Window1 in Window2 or apply binding to that of Window2?

Thanks

To be concise, by adopting the suggestion from the provided link as such

public partial class Window2 : NameSpaceRecipeApp.Window1
    {
        public Window2()
        {
            InitializeComponent();
        }
    }

or even as

public partial class Window2 : NameSpace RecipeApp.Window1
    {
        public Window2()
        {
            InitializeComponent();
        }
    }

errors suffice. With the base class as

public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();
        }
    }

the error message is "The type or namespace name 'NameSpaceRecipeApp' could not be found (are you missing a using directive or an assembly reference?)".

I also recieve the error concerning partial classes stating "Partial declarations of 'Classname' must not specify different base classes".

Any idea would be great.

Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.