I want to add a folder containing xaml and cs files plus other directories to a different project on VS. For some reason when I drag the folder from windows explorer to the project where I will like to place that directory visual studio will not let me. Because of that I am manually adding each file and every time I encounter a directory I have to create it. Maybe it is because I am using team foundation server.
Anyways I am adding the files manually so I click on the folder that I want to add the files on visual studio then click on add existing files. Then I select the xaml and code behind file:
when I click add the files get added but visual studio does not recognize that Bytes.xaml.cs is the code behind!
Do I have to manually add a window then copy and paste the contents of the file?
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.
Just right click the project, choose Add -> Window and that will add a new xaml file along with its corresponding .
To open this page, choose the Tools menu and then choose Options. To access the XAML Designer property page, choose the XAML Designer node. Settings for the XAML Designer are applied when you open the document. So, if you make changes to the settings, you need to close and then reopen Visual Studio to see the changes.
How to Open an XAML File. XAML files are used in . NET programming, so they can also be opened with Microsoft's Visual Studio. However, since they're text-based XML files, you can also open one and edit one with Windows Notepad or any other text editor.
Edit your .csproj file to add a "DependentUpon" element below your "Compile" element for the .xaml.cs file so that it will appear "inside" the .xaml file not simply below it.:
<Compile Include="BytesDisplay\SubControls\Bytes.xaml.cs">
<DependentUpon>Bytes.xaml</DependentUpon>
</Compile>
To easily edit the .csproj file:
Right-click the project and select "Unload Project"
Right-click the project node again and select "Edit [projectname].csproj"
Edit the XML, then close the file
Right-click the project node again and select "Reload Project"
If you drag-and-drop the .xaml file from Windows Explorer into the Solution Explorer window, it will automatically add the .xaml with the code-behind .cs file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With