954,514 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Window to window binding and ownership

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

ibdatx
Light Poster
32 posts since Apr 2009
Reputation Points: 10
Solved Threads: 0
 

> 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

__avd
Posting Genius (adatapost)
Moderator
8,648 posts since Oct 2008
Reputation Points: 2,136
Solved Threads: 1,241
 

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

ibdatx
Light Poster
32 posts since Apr 2009
Reputation Points: 10
Solved Threads: 0
 

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

ibdatx
Light Poster
32 posts since Apr 2009
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: