Hi everyone,
at the moment I'm trying to open a new window out of a clickevent from my mainwindow. something like this
ChildWindow window = new ChildWindow();
childwindow.show();
everthing is ok until I try to build the app. Then the following error occurs:
The name 'InitializeComponent' does not exist in the current context
Can somebody help me with this

problems opening a new window
Tommief
Well, the error is not the mistyped code, otherwise the compiler wouldn't have even displayed "Initialize Component does not exist" error.
InitializeComponent is called from in the window/page/etc's contructor in the code-behind file. This is to "Initialize" the components that are generated in the .g.cs/.g.vb partial class. If you are instantiating a XAML with Code-behind Window, make sure that InitializeComponent is called from within the Code-behind's constructor. (You may need to build the project at least once to generate the partial class).
I hope this helps
Jaco
Roman Koreshkov
Does ChildWindow have a corresponding XAML page or was it defined in code only If defined in code, remove the InitializeComponent() call from the constructor. For code generated by the WPF build system, the InitializeComponent method definition exists in the window's .g.cs or .g.vb file.
Rich Baker
no, the childwindow has a corresponding xaml, but the problem was solved. in my code I had pasted something and that went wrong. I pasted it on the wrong spot. When I opened the app again the day after, I saw an error and some lines were missing due the copy/paste of the day before. Then I tried to recode the lines that where overwritten by the paste and I had mistyped my x:class property. in stead of ChildWindow I typed CildWindow. I took a while before I saw it. Stupid, don't have to mention it :-).
Thanks for the replies
David Jordan
ChildWindow window = new ChildWindow();
childwindow.show();
Is that copy/pasted code Or was that an error in the post (but it's alright in the code)