Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to import XAML pages together with code-behind in Visual Studio 2012?

I am trying to port my Windows 8 Store application from Developer Preview to RTM now and I got problems with importing old XAML layout into the newly created project (the old project isn't runnable anymore).

Whenever I import .xaml and .xaml.cs files, they are not recognized as a single file. Rather, two different files are added. How can I import both files as a single "entity", as it happens if I add a new XAML page to my project?

like image 362
Alexander Galkin Avatar asked Sep 15 '12 10:09

Alexander Galkin


People also ask

What is code-behind XAML?

Code-behind is a term used to describe the code that is joined with markup-defined objects, when a XAML page is markup-compiled. This topic describes requirements for code-behind as well as an alternative inline code mechanism for code in XAML.

How do I add a page to XAML?

xaml. Go to Solution Explorer-->Your Project-->Portable-->Right click-->Add-->New Item (Ctrl+Shift+A). Now, select the Forms XAML page and give the name (SecondPage. xaml).

How do I find the XAML code in Visual Studio?

To open the XAML Designer, right-click a XAML file in Solution Explorer and choose View Designer. to switch which window appears on top: either the artboard or the XAML editor.


1 Answers

Corresponding .cs or .vb files are imported on import of .xaml files,
but in VS2012 there is one catch:

    enter image description here    you must import only one XAML file at a time

If you mark more than one file in file selector, XAML files are not paired correctly with their corresponding code files (even in case if you switch filter to All Files and then select both XAML and code files).

like image 135
miroxlav Avatar answered Oct 01 '22 08:10

miroxlav