Instead of excluding it, by mistake, I deleted the .cs code behind file for an Xaml file. Now, I don't know how to add the code behind.
This Window is empty with no UI controls on it. "View Code" is disabled and I can't see the Events (lightning bolt icon) anywhere for this xaml.
Please help.
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.
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.
Just right click the project, choose Add -> Window and that will add a new xaml file along with its corresponding .
There are two required steps and one optional:
<DependentUpon>
element below your <Compile>
element for the .xaml.cs file so that it will appear "inside" the .xaml file not simply below it. If you are updating project to be edited with Blend (v4), this third step is required, not optional, in order to use the inspector to add events to controls.To easily edit the .csproj file:
If you're using VB.NET, everything the same, just replace "cs" with "vb".
I think all you have to do is create a new class file and name it exactly like your xaml with the cs extension...
test.xaml
test.xaml.cs
works in vb....
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